ยปCore Development>Code coverage>Lib/test/test_macpath.py

Python code coverage for Lib/test/test_macpath.py

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