Exemplo n.º 1
0
def test_parts():
    parts = paths.norm_parts("/a/b/c")
    assert len(parts) == 4
    assert parts[0] == "/"
    assert parts[1] == "a/"
    assert parts[2] == "b/"
    assert parts[3] == "c"

    parts = paths.norm_parts("/a/b/")
    assert len(parts) == 3
    assert parts[0] == "/"
    assert parts[1] == "a/"
    assert parts[2] == "b/"
Exemplo n.º 2
0
 def _node_path_from_example_path(path):
     # Guess the node based on what directory the example is in
     parts = paths.norm_parts(path)
     # Remove the examples prefix
     assert parts.pop(1) == "examples/"
     # Remove the filename from the end
     parts.pop()
     # Put the path back together
     nodepath = "".join(parts)
     if nodepath.endswith("/"):
         nodepath = nodepath[:-1]
     return nodepath