1import macpath 2from test import test_support, test_genericpath 3import unittest 4 5 6class MacPathTestCase(unittest.TestCase): 7 8 def test_abspath(self): 9 self.assertEqual(macpath.abspath("xx:yy"), "xx:yy") 10 11 def test_isabs(self): 12 isabs = macpath.isabs 13 self.assertTrue(isabs("xx:yy")) 14 self.assertTrue(isabs("xx:yy:")) 15 self.assertTrue(isabs("xx:")) 16 self.assertFalse(isabs("foo")) 17 self.assertFalse(isabs(":foo")) 18 self.assertFalse(isabs(":foo:bar")) 19 self.assertFalse(isabs(":foo:bar:")) 20 21 def test_split(self): 22 split = macpath.split 23 self.assertEqual(split("foo:bar"), 24 ('foo:', 'bar')) 25 self.assertEqual(split("conky:mountpoint:foo:bar"), 26 ('conky:mountpoint:foo', 'bar')) 27 28 self.assertEqual(split(":"), ('', '')) 29 self.assertEqual(split(":conky:mountpoint:"), 30 (':conky:mountpoint', '')) 31 32 def test_splitext(self): 33 splitext = macpath.splitext 34 self.assertEqual(splitext(":foo.ext"), (':foo', '.ext')) 35 self.assertEqual(splitext("foo:foo.ext"), ('foo:foo', '.ext')) 36 self.assertEqual(splitext(".ext"), ('.ext', '')) 37 self.assertEqual(splitext("foo.ext:foo"), ('foo.ext:foo', '')) 38 self.assertEqual(splitext(":foo.ext:"), (':foo.ext:', '')) 39 self.assertEqual(splitext(""), ('', '')) 40 self.assertEqual(splitext("foo.bar.ext"), ('foo.bar', '.ext')) 41 42 def test_normpath(self): 43 # Issue 5827: Make sure normpath preserves unicode 44 for path in (u'', u'.', u'/', u'\\', u':', u'///foo/.//bar//'): 45 self.assertIsInstance(macpath.normpath(path), unicode, 46 'normpath() returned str instead of unicode') 47 48class MacCommonTest(test_genericpath.CommonTest): 49 pathmodule = macpath 50 51 52def test_main(): 53 test_support.run_unittest(MacPathTestCase, MacCommonTest) 54 55 56if __name__ == "__main__": 57 test_main() 58