2
sys.path.insert(0, "../src")
6
class PathTest(unittest.TestCase):
7
"""Test basic path functions"""
8
def test_deltree(self):
9
"""Test deleting a tree"""
10
assert not os.system("rm -rf testfiles/output")
11
assert not os.system("cp -a testfiles/deltree testfiles/output")
12
p = Path("testfiles/output")
15
assert not p.type, p.type
17
def test_compare(self):
18
"""Test directory comparisons"""
19
assert not os.system("cp -a testfiles/dir1 testfiles/output")
20
assert Path("testfiles/dir1").compare_recursive(
21
Path("testfiles/output"), 1)
22
assert not Path("testfiles/dir1").compare_recursive(
23
Path("testfiles/dir2"), 1)
26
"""Test path quoting"""
28
assert p.quote() == '"hello"'
29
assert p.quote("\\") == '"\\\\"', p.quote("\\")
30
assert p.quote("$HELLO") == '"\\$HELLO"'
32
def test_unquote(self):
33
"""Test path unquoting"""
34
p = Path("foo") # just to provide unquote function
36
"""Run test on string s"""
37
quoted_version = p.quote(s)
38
unquoted = p.unquote(quoted_version)
39
assert unquoted == s, (unquoted, s)
45
def test_canonical(self):
46
"""Test getting canonical version of path"""
47
c = Path(".").get_canonical()
50
c = Path("//foo/bar/./").get_canonical()
51
assert c == "/foo/bar", c
53
if __name__ == "__main__": unittest.main()