Require implementations for warnings.showwarning() support the 'line' argument.
[python.git] / Lib / test / test_macpath.py
blob2449b0a1fb0909de4fa4589dee6bb929c3e788b9
1 import macpath
2 from test import test_support
3 import unittest
6 class MacPathTestCase(unittest.TestCase):
8 def test_abspath(self):
9 self.assert_(macpath.abspath("xx:yy") == "xx:yy")
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:"))
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")
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'))
38 self.assertEquals(split(":"), ('', ''))
39 self.assertEquals(split(":conky:mountpoint:"),
40 (':conky:mountpoint', ''))
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'))
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'))
58 def test_main():
59 test_support.run_unittest(MacPathTestCase)
62 if __name__ == "__main__":
63 test_main()