|
1 import macpath |
|
2 from test import test_support |
|
3 import unittest |
|
4 |
|
5 |
|
6 class MacPathTestCase(unittest.TestCase): |
|
7 |
|
8 def test_abspath(self): |
|
9 self.assert_(macpath.abspath("xx:yy") == "xx:yy") |
|
10 |
|
11 def test_isabs(self): |
|
12 isabs = macpath.isabs |
|
13 self.assert_(isabs("xx:yy")) |
|
14 self.assert_(isabs("xx:yy:")) |
|
15 self.assert_(isabs("xx:")) |
|
16 self.failIf(isabs("foo")) |
|
17 self.failIf(isabs(":foo")) |
|
18 self.failIf(isabs(":foo:bar")) |
|
19 self.failIf(isabs(":foo:bar:")) |
|
20 |
|
21 |
|
22 def test_commonprefix(self): |
|
23 commonprefix = macpath.commonprefix |
|
24 self.assert_(commonprefix(["home:swenson:spam", "home:swen:spam"]) |
|
25 == "home:swen") |
|
26 self.assert_(commonprefix([":home:swen:spam", ":home:swen:eggs"]) |
|
27 == ":home:swen:") |
|
28 self.assert_(commonprefix([":home:swen:spam", ":home:swen:spam"]) |
|
29 == ":home:swen:spam") |
|
30 |
|
31 def test_split(self): |
|
32 split = macpath.split |
|
33 self.assertEquals(split("foo:bar"), |
|
34 ('foo:', 'bar')) |
|
35 self.assertEquals(split("conky:mountpoint:foo:bar"), |
|
36 ('conky:mountpoint:foo', 'bar')) |
|
37 |
|
38 self.assertEquals(split(":"), ('', '')) |
|
39 self.assertEquals(split(":conky:mountpoint:"), |
|
40 (':conky:mountpoint', '')) |
|
41 |
|
42 def test_splitdrive(self): |
|
43 splitdrive = macpath.splitdrive |
|
44 self.assertEquals(splitdrive("foo:bar"), ('', 'foo:bar')) |
|
45 self.assertEquals(splitdrive(":foo:bar"), ('', ':foo:bar')) |
|
46 |
|
47 def test_splitext(self): |
|
48 splitext = macpath.splitext |
|
49 self.assertEquals(splitext(":foo.ext"), (':foo', '.ext')) |
|
50 self.assertEquals(splitext("foo:foo.ext"), ('foo:foo', '.ext')) |
|
51 self.assertEquals(splitext(".ext"), ('.ext', '')) |
|
52 self.assertEquals(splitext("foo.ext:foo"), ('foo.ext:foo', '')) |
|
53 self.assertEquals(splitext(":foo.ext:"), (':foo.ext:', '')) |
|
54 self.assertEquals(splitext(""), ('', '')) |
|
55 self.assertEquals(splitext("foo.bar.ext"), ('foo.bar', '.ext')) |
|
56 |
|
57 |
|
58 def test_main(): |
|
59 test_support.run_unittest(MacPathTestCase) |
|
60 |
|
61 |
|
62 if __name__ == "__main__": |
|
63 test_main() |