Exemple #1
0
def test_normalize():
    assert paths.normalize("/") == "/"
    assert paths.normalize("/a/../") == "/"
    assert paths.normalize("/a/b/c") == "/a/b/c"
    assert paths.normalize("/a/b/c/") == "/a/b/c/"
    assert paths.normalize("/a/b/../c") == "/a/c"
    assert paths.normalize("/a/b/../c/") == "/a/c/"
    assert paths.normalize("/.") == "/"
    assert paths.normalize("/./") == "/"
    assert paths.normalize("/a/.") == "/a/"
    assert paths.normalize("/a/b/./c") == "/a/b/c"
    assert paths.normalize("/a/b/./c/") == "/a/b/c/"

    assert paths.normalize("/a/b//c") == "/a/b/c"
    assert paths.normalize("//a/b//c") == "/a/b/c"
    assert paths.normalize("//a/b//c//") == "/a/b/c/"

    with nose.tools.assert_raises(ValueError):
        _ = paths.normalize_abs("")
    with nose.tools.assert_raises(ValueError):
        _ = paths.normalize_abs("a/b/c")

    assert paths.normalize("/../a") == "/a"
    assert paths.normalize("/a/b/../../..") == "/"
Exemple #2
0
 def zipname(path):
     return paths.normalize_abs(path)[1:]
Exemple #3
0
 def file_path(self, path):
     path = paths.normalize_abs(path)
     return os.path.join(self.dirpath, path[1:])