Martin v. Löwis | de33379 | 2002-12-12 20:30:20 +0000 | [diff] [blame] | 1 | import macpath |
Benjamin Peterson | ee8712c | 2008-05-20 21:35:26 +0000 | [diff] [blame] | 2 | from test import support |
Martin v. Löwis | de33379 | 2002-12-12 20:30:20 +0000 | [diff] [blame] | 3 | import unittest |
| 4 | |
| 5 | |
| 6 | class MacPathTestCase(unittest.TestCase): |
| 7 | |
| 8 | def test_abspath(self): |
Guido van Rossum | e61fd5b | 2007-07-11 12:20:59 +0000 | [diff] [blame] | 9 | self.assertEqual(macpath.abspath("xx:yy"), "xx:yy") |
Martin v. Löwis | de33379 | 2002-12-12 20:30:20 +0000 | [diff] [blame] | 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')) |
Guido van Rossum | d8faa36 | 2007-04-27 19:54:29 +0000 | [diff] [blame] | 51 | self.assertEquals(splitext(".ext"), ('.ext', '')) |
Martin v. Löwis | de33379 | 2002-12-12 20:30:20 +0000 | [diff] [blame] | 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(): |
Benjamin Peterson | ee8712c | 2008-05-20 21:35:26 +0000 | [diff] [blame] | 59 | support.run_unittest(MacPathTestCase) |
Martin v. Löwis | de33379 | 2002-12-12 20:30:20 +0000 | [diff] [blame] | 60 | |
| 61 | |
| 62 | if __name__ == "__main__": |
| 63 | test_main() |