Merge other tests from test_*path.py into test_genericpath.CommonTest, and do some cleanup.

This commit is contained in:
Florent Xicluna 2010-03-08 12:42:20 +00:00
parent 19b02d4558
commit e3ed2e02be
3 changed files with 55 additions and 128 deletions

View file

@ -26,23 +26,6 @@ class MacPathTestCase(unittest.TestCase):
self.assertFalse(isabs(b":foo:bar"))
self.assertFalse(isabs(b":foo:bar:"))
def test_commonprefix(self):
commonprefix = macpath.commonprefix
self.assertEqual(commonprefix(["home:swenson:spam", "home:swen:spam"]),
"home:swen")
self.assertEqual(commonprefix([":home:swen:spam", ":home:swen:eggs"]),
":home:swen:")
self.assertEqual(commonprefix([":home:swen:spam", ":home:swen:spam"]),
":home:swen:spam")
self.assertTrue(commonprefix([b"home:swenson:spam", b"home:swen:spam"])
== b"home:swen")
self.assertTrue(commonprefix([b":home:swen:spam", b":home:swen:eggs"])
== b":home:swen:")
self.assertTrue(commonprefix([b":home:swen:spam", b":home:swen:spam"])
== b":home:swen:spam")
def test_split(self):
split = macpath.split
self.assertEqual(split("foo:bar"),
@ -54,36 +37,28 @@ class MacPathTestCase(unittest.TestCase):
self.assertEqual(split(":conky:mountpoint:"),
(':conky:mountpoint', ''))
self.assertEquals(split(b"foo:bar"),
self.assertEqual(split(b"foo:bar"),
(b'foo:', b'bar'))
self.assertEquals(split(b"conky:mountpoint:foo:bar"),
self.assertEqual(split(b"conky:mountpoint:foo:bar"),
(b'conky:mountpoint:foo', b'bar'))
self.assertEquals(split(b":"), (b'', b''))
self.assertEquals(split(b":conky:mountpoint:"),
self.assertEqual(split(b":"), (b'', b''))
self.assertEqual(split(b":conky:mountpoint:"),
(b':conky:mountpoint', b''))
def test_join(self):
join = macpath.join
self.assertEquals(join('a', 'b'), ':a:b')
self.assertEquals(join('', 'a:b'), 'a:b')
self.assertEquals(join('a:b', 'c'), 'a:b:c')
self.assertEquals(join('a:b', ':c'), 'a:b:c')
self.assertEquals(join('a', ':b', ':c'), ':a:b:c')
self.assertEqual(join('a', 'b'), ':a:b')
self.assertEqual(join('', 'a:b'), 'a:b')
self.assertEqual(join('a:b', 'c'), 'a:b:c')
self.assertEqual(join('a:b', ':c'), 'a:b:c')
self.assertEqual(join('a', ':b', ':c'), ':a:b:c')
self.assertEquals(join(b'a', b'b'), b':a:b')
self.assertEquals(join(b'', b'a:b'), b'a:b')
self.assertEquals(join(b'a:b', b'c'), b'a:b:c')
self.assertEquals(join(b'a:b', b':c'), b'a:b:c')
self.assertEquals(join(b'a', b':b', b':c'), b':a:b:c')
def test_splitdrive(self):
splitdrive = macpath.splitdrive
self.assertEqual(splitdrive("foo:bar"), ('', 'foo:bar'))
self.assertEqual(splitdrive(":foo:bar"), ('', ':foo:bar'))
self.assertEquals(splitdrive(b"foo:bar"), (b'', b'foo:bar'))
self.assertEquals(splitdrive(b":foo:bar"), (b'', b':foo:bar'))
self.assertEqual(join(b'a', b'b'), b':a:b')
self.assertEqual(join(b'', b'a:b'), b'a:b')
self.assertEqual(join(b'a:b', b'c'), b'a:b:c')
self.assertEqual(join(b'a:b', b':c'), b'a:b:c')
self.assertEqual(join(b'a', b':b', b':c'), b':a:b:c')
def test_splitext(self):
splitext = macpath.splitext
@ -95,27 +70,27 @@ class MacPathTestCase(unittest.TestCase):
self.assertEqual(splitext(""), ('', ''))
self.assertEqual(splitext("foo.bar.ext"), ('foo.bar', '.ext'))
self.assertEquals(splitext(b":foo.ext"), (b':foo', b'.ext'))
self.assertEquals(splitext(b"foo:foo.ext"), (b'foo:foo', b'.ext'))
self.assertEquals(splitext(b".ext"), (b'.ext', b''))
self.assertEquals(splitext(b"foo.ext:foo"), (b'foo.ext:foo', b''))
self.assertEquals(splitext(b":foo.ext:"), (b':foo.ext:', b''))
self.assertEquals(splitext(b""), (b'', b''))
self.assertEquals(splitext(b"foo.bar.ext"), (b'foo.bar', b'.ext'))
self.assertEqual(splitext(b":foo.ext"), (b':foo', b'.ext'))
self.assertEqual(splitext(b"foo:foo.ext"), (b'foo:foo', b'.ext'))
self.assertEqual(splitext(b".ext"), (b'.ext', b''))
self.assertEqual(splitext(b"foo.ext:foo"), (b'foo.ext:foo', b''))
self.assertEqual(splitext(b":foo.ext:"), (b':foo.ext:', b''))
self.assertEqual(splitext(b""), (b'', b''))
self.assertEqual(splitext(b"foo.bar.ext"), (b'foo.bar', b'.ext'))
def test_ismount(self):
ismount = macpath.ismount
self.assertEquals(ismount("a:"), True)
self.assertEquals(ismount("a:b"), False)
self.assertEquals(ismount("a:b:"), True)
self.assertEquals(ismount(""), False)
self.assertEquals(ismount(":"), False)
self.assertEqual(ismount("a:"), True)
self.assertEqual(ismount("a:b"), False)
self.assertEqual(ismount("a:b:"), True)
self.assertEqual(ismount(""), False)
self.assertEqual(ismount(":"), False)
self.assertEquals(ismount(b"a:"), True)
self.assertEquals(ismount(b"a:b"), False)
self.assertEquals(ismount(b"a:b:"), True)
self.assertEquals(ismount(b""), False)
self.assertEquals(ismount(b":"), False)
self.assertEqual(ismount(b"a:"), True)
self.assertEqual(ismount(b"a:b"), False)
self.assertEqual(ismount(b"a:b:"), True)
self.assertEqual(ismount(b""), False)
self.assertEqual(ismount(b":"), False)
def test_normpath(self):
normpath = macpath.normpath