PyXR

c:\python24\lib \ test \ test_macpath.py



0001 import macpath
0002 from test import test_support
0003 import unittest
0004 
0005 
0006 class MacPathTestCase(unittest.TestCase):
0007 
0008     def test_abspath(self):
0009         self.assert_(macpath.abspath("xx:yy") == "xx:yy")
0010 
0011     def test_isabs(self):
0012         isabs = macpath.isabs
0013         self.assert_(isabs("xx:yy"))
0014         self.assert_(isabs("xx:yy:"))
0015         self.assert_(isabs("xx:"))
0016         self.failIf(isabs("foo"))
0017         self.failIf(isabs(":foo"))
0018         self.failIf(isabs(":foo:bar"))
0019         self.failIf(isabs(":foo:bar:"))
0020 
0021 
0022     def test_commonprefix(self):
0023         commonprefix = macpath.commonprefix
0024         self.assert_(commonprefix(["home:swenson:spam", "home:swen:spam"])
0025                      == "home:swen")
0026         self.assert_(commonprefix([":home:swen:spam", ":home:swen:eggs"])
0027                      == ":home:swen:")
0028         self.assert_(commonprefix([":home:swen:spam", ":home:swen:spam"])
0029                      == ":home:swen:spam")
0030 
0031     def test_split(self):
0032         split = macpath.split
0033         self.assertEquals(split("foo:bar"),
0034                           ('foo:', 'bar'))
0035         self.assertEquals(split("conky:mountpoint:foo:bar"),
0036                           ('conky:mountpoint:foo', 'bar'))
0037 
0038         self.assertEquals(split(":"), ('', ''))
0039         self.assertEquals(split(":conky:mountpoint:"),
0040                           (':conky:mountpoint', ''))
0041 
0042     def test_splitdrive(self):
0043         splitdrive = macpath.splitdrive
0044         self.assertEquals(splitdrive("foo:bar"), ('', 'foo:bar'))
0045         self.assertEquals(splitdrive(":foo:bar"), ('', ':foo:bar'))
0046 
0047     def test_splitext(self):
0048         splitext = macpath.splitext
0049         self.assertEquals(splitext(":foo.ext"), (':foo', '.ext'))
0050         self.assertEquals(splitext("foo:foo.ext"), ('foo:foo', '.ext'))
0051         self.assertEquals(splitext(".ext"), ('', '.ext'))
0052         self.assertEquals(splitext("foo.ext:foo"), ('foo.ext:foo', ''))
0053         self.assertEquals(splitext(":foo.ext:"), (':foo.ext:', ''))
0054         self.assertEquals(splitext(""), ('', ''))
0055         self.assertEquals(splitext("foo.bar.ext"), ('foo.bar', '.ext'))
0056 
0057 
0058 def test_main():
0059     test_support.run_unittest(MacPathTestCase)
0060 
0061 
0062 if __name__ == "__main__":
0063     test_main()
0064 

Generated by PyXR 0.9.4
SourceForge.net Logo