1 | n/a | import macpath |
---|
2 | n/a | from test import test_genericpath |
---|
3 | n/a | import unittest |
---|
4 | n/a | |
---|
5 | n/a | |
---|
6 | n/a | class MacPathTestCase(unittest.TestCase): |
---|
7 | n/a | |
---|
8 | n/a | def test_abspath(self): |
---|
9 | n/a | self.assertEqual(macpath.abspath("xx:yy"), "xx:yy") |
---|
10 | n/a | |
---|
11 | n/a | def test_isabs(self): |
---|
12 | n/a | isabs = macpath.isabs |
---|
13 | n/a | self.assertTrue(isabs("xx:yy")) |
---|
14 | n/a | self.assertTrue(isabs("xx:yy:")) |
---|
15 | n/a | self.assertTrue(isabs("xx:")) |
---|
16 | n/a | self.assertFalse(isabs("foo")) |
---|
17 | n/a | self.assertFalse(isabs(":foo")) |
---|
18 | n/a | self.assertFalse(isabs(":foo:bar")) |
---|
19 | n/a | self.assertFalse(isabs(":foo:bar:")) |
---|
20 | n/a | |
---|
21 | n/a | self.assertTrue(isabs(b"xx:yy")) |
---|
22 | n/a | self.assertTrue(isabs(b"xx:yy:")) |
---|
23 | n/a | self.assertTrue(isabs(b"xx:")) |
---|
24 | n/a | self.assertFalse(isabs(b"foo")) |
---|
25 | n/a | self.assertFalse(isabs(b":foo")) |
---|
26 | n/a | self.assertFalse(isabs(b":foo:bar")) |
---|
27 | n/a | self.assertFalse(isabs(b":foo:bar:")) |
---|
28 | n/a | |
---|
29 | n/a | def test_split(self): |
---|
30 | n/a | split = macpath.split |
---|
31 | n/a | self.assertEqual(split("foo:bar"), |
---|
32 | n/a | ('foo:', 'bar')) |
---|
33 | n/a | self.assertEqual(split("conky:mountpoint:foo:bar"), |
---|
34 | n/a | ('conky:mountpoint:foo', 'bar')) |
---|
35 | n/a | |
---|
36 | n/a | self.assertEqual(split(":"), ('', '')) |
---|
37 | n/a | self.assertEqual(split(":conky:mountpoint:"), |
---|
38 | n/a | (':conky:mountpoint', '')) |
---|
39 | n/a | |
---|
40 | n/a | self.assertEqual(split(b"foo:bar"), |
---|
41 | n/a | (b'foo:', b'bar')) |
---|
42 | n/a | self.assertEqual(split(b"conky:mountpoint:foo:bar"), |
---|
43 | n/a | (b'conky:mountpoint:foo', b'bar')) |
---|
44 | n/a | |
---|
45 | n/a | self.assertEqual(split(b":"), (b'', b'')) |
---|
46 | n/a | self.assertEqual(split(b":conky:mountpoint:"), |
---|
47 | n/a | (b':conky:mountpoint', b'')) |
---|
48 | n/a | |
---|
49 | n/a | def test_join(self): |
---|
50 | n/a | join = macpath.join |
---|
51 | n/a | self.assertEqual(join('a', 'b'), ':a:b') |
---|
52 | n/a | self.assertEqual(join(':a', 'b'), ':a:b') |
---|
53 | n/a | self.assertEqual(join(':a:', 'b'), ':a:b') |
---|
54 | n/a | self.assertEqual(join(':a::', 'b'), ':a::b') |
---|
55 | n/a | self.assertEqual(join(':a', '::b'), ':a::b') |
---|
56 | n/a | self.assertEqual(join('a', ':'), ':a:') |
---|
57 | n/a | self.assertEqual(join('a:', ':'), 'a:') |
---|
58 | n/a | self.assertEqual(join('a', ''), ':a:') |
---|
59 | n/a | self.assertEqual(join('a:', ''), 'a:') |
---|
60 | n/a | self.assertEqual(join('', ''), '') |
---|
61 | n/a | self.assertEqual(join('', 'a:b'), 'a:b') |
---|
62 | n/a | self.assertEqual(join('', 'a', 'b'), ':a:b') |
---|
63 | n/a | self.assertEqual(join('a:b', 'c'), 'a:b:c') |
---|
64 | n/a | self.assertEqual(join('a:b', ':c'), 'a:b:c') |
---|
65 | n/a | self.assertEqual(join('a', ':b', ':c'), ':a:b:c') |
---|
66 | n/a | self.assertEqual(join('a', 'b:'), 'b:') |
---|
67 | n/a | self.assertEqual(join('a:', 'b:'), 'b:') |
---|
68 | n/a | |
---|
69 | n/a | self.assertEqual(join(b'a', b'b'), b':a:b') |
---|
70 | n/a | self.assertEqual(join(b':a', b'b'), b':a:b') |
---|
71 | n/a | self.assertEqual(join(b':a:', b'b'), b':a:b') |
---|
72 | n/a | self.assertEqual(join(b':a::', b'b'), b':a::b') |
---|
73 | n/a | self.assertEqual(join(b':a', b'::b'), b':a::b') |
---|
74 | n/a | self.assertEqual(join(b'a', b':'), b':a:') |
---|
75 | n/a | self.assertEqual(join(b'a:', b':'), b'a:') |
---|
76 | n/a | self.assertEqual(join(b'a', b''), b':a:') |
---|
77 | n/a | self.assertEqual(join(b'a:', b''), b'a:') |
---|
78 | n/a | self.assertEqual(join(b'', b''), b'') |
---|
79 | n/a | self.assertEqual(join(b'', b'a:b'), b'a:b') |
---|
80 | n/a | self.assertEqual(join(b'', b'a', b'b'), b':a:b') |
---|
81 | n/a | self.assertEqual(join(b'a:b', b'c'), b'a:b:c') |
---|
82 | n/a | self.assertEqual(join(b'a:b', b':c'), b'a:b:c') |
---|
83 | n/a | self.assertEqual(join(b'a', b':b', b':c'), b':a:b:c') |
---|
84 | n/a | self.assertEqual(join(b'a', b'b:'), b'b:') |
---|
85 | n/a | self.assertEqual(join(b'a:', b'b:'), b'b:') |
---|
86 | n/a | |
---|
87 | n/a | def test_splitext(self): |
---|
88 | n/a | splitext = macpath.splitext |
---|
89 | n/a | self.assertEqual(splitext(":foo.ext"), (':foo', '.ext')) |
---|
90 | n/a | self.assertEqual(splitext("foo:foo.ext"), ('foo:foo', '.ext')) |
---|
91 | n/a | self.assertEqual(splitext(".ext"), ('.ext', '')) |
---|
92 | n/a | self.assertEqual(splitext("foo.ext:foo"), ('foo.ext:foo', '')) |
---|
93 | n/a | self.assertEqual(splitext(":foo.ext:"), (':foo.ext:', '')) |
---|
94 | n/a | self.assertEqual(splitext(""), ('', '')) |
---|
95 | n/a | self.assertEqual(splitext("foo.bar.ext"), ('foo.bar', '.ext')) |
---|
96 | n/a | |
---|
97 | n/a | self.assertEqual(splitext(b":foo.ext"), (b':foo', b'.ext')) |
---|
98 | n/a | self.assertEqual(splitext(b"foo:foo.ext"), (b'foo:foo', b'.ext')) |
---|
99 | n/a | self.assertEqual(splitext(b".ext"), (b'.ext', b'')) |
---|
100 | n/a | self.assertEqual(splitext(b"foo.ext:foo"), (b'foo.ext:foo', b'')) |
---|
101 | n/a | self.assertEqual(splitext(b":foo.ext:"), (b':foo.ext:', b'')) |
---|
102 | n/a | self.assertEqual(splitext(b""), (b'', b'')) |
---|
103 | n/a | self.assertEqual(splitext(b"foo.bar.ext"), (b'foo.bar', b'.ext')) |
---|
104 | n/a | |
---|
105 | n/a | def test_ismount(self): |
---|
106 | n/a | ismount = macpath.ismount |
---|
107 | n/a | self.assertEqual(ismount("a:"), True) |
---|
108 | n/a | self.assertEqual(ismount("a:b"), False) |
---|
109 | n/a | self.assertEqual(ismount("a:b:"), True) |
---|
110 | n/a | self.assertEqual(ismount(""), False) |
---|
111 | n/a | self.assertEqual(ismount(":"), False) |
---|
112 | n/a | |
---|
113 | n/a | self.assertEqual(ismount(b"a:"), True) |
---|
114 | n/a | self.assertEqual(ismount(b"a:b"), False) |
---|
115 | n/a | self.assertEqual(ismount(b"a:b:"), True) |
---|
116 | n/a | self.assertEqual(ismount(b""), False) |
---|
117 | n/a | self.assertEqual(ismount(b":"), False) |
---|
118 | n/a | |
---|
119 | n/a | def test_normpath(self): |
---|
120 | n/a | normpath = macpath.normpath |
---|
121 | n/a | self.assertEqual(normpath("a:b"), "a:b") |
---|
122 | n/a | self.assertEqual(normpath("a"), ":a") |
---|
123 | n/a | self.assertEqual(normpath("a:b::c"), "a:c") |
---|
124 | n/a | self.assertEqual(normpath("a:b:c:::d"), "a:d") |
---|
125 | n/a | self.assertRaises(macpath.norm_error, normpath, "a::b") |
---|
126 | n/a | self.assertRaises(macpath.norm_error, normpath, "a:b:::c") |
---|
127 | n/a | self.assertEqual(normpath(":"), ":") |
---|
128 | n/a | self.assertEqual(normpath("a:"), "a:") |
---|
129 | n/a | self.assertEqual(normpath("a:b:"), "a:b") |
---|
130 | n/a | |
---|
131 | n/a | self.assertEqual(normpath(b"a:b"), b"a:b") |
---|
132 | n/a | self.assertEqual(normpath(b"a"), b":a") |
---|
133 | n/a | self.assertEqual(normpath(b"a:b::c"), b"a:c") |
---|
134 | n/a | self.assertEqual(normpath(b"a:b:c:::d"), b"a:d") |
---|
135 | n/a | self.assertRaises(macpath.norm_error, normpath, b"a::b") |
---|
136 | n/a | self.assertRaises(macpath.norm_error, normpath, b"a:b:::c") |
---|
137 | n/a | self.assertEqual(normpath(b":"), b":") |
---|
138 | n/a | self.assertEqual(normpath(b"a:"), b"a:") |
---|
139 | n/a | self.assertEqual(normpath(b"a:b:"), b"a:b") |
---|
140 | n/a | |
---|
141 | n/a | |
---|
142 | n/a | class MacCommonTest(test_genericpath.CommonTest, unittest.TestCase): |
---|
143 | n/a | pathmodule = macpath |
---|
144 | n/a | |
---|
145 | n/a | test_relpath_errors = None |
---|
146 | n/a | |
---|
147 | n/a | |
---|
148 | n/a | if __name__ == "__main__": |
---|
149 | n/a | unittest.main() |
---|