diff options
author | Martin v. Löwis <martin@v.loewis.de> | 2007-03-07 11:04:33 (GMT) |
---|---|---|
committer | Martin v. Löwis <martin@v.loewis.de> | 2007-03-07 11:04:33 (GMT) |
commit | 05c075d629fc81035b438e3b146872dc7799f260 (patch) | |
tree | 4240955ee3ea5894d0c068c9669244a7200e768c /Lib/test | |
parent | f08c073ded5a7cf5786f9a561e3d9529def81b6e (diff) | |
download | cpython-05c075d629fc81035b438e3b146872dc7799f260.zip cpython-05c075d629fc81035b438e3b146872dc7799f260.tar.gz cpython-05c075d629fc81035b438e3b146872dc7799f260.tar.bz2 |
Bug #1115886: os.path.splitext('.cshrc') gives now ('.cshrc', '').
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_macpath.py | 2 | ||||
-rw-r--r-- | Lib/test/test_ntpath.py | 3 | ||||
-rw-r--r-- | Lib/test/test_posixpath.py | 28 |
3 files changed, 23 insertions, 10 deletions
diff --git a/Lib/test/test_macpath.py b/Lib/test/test_macpath.py index 3a3cf04..2449b0a 100644 --- a/Lib/test/test_macpath.py +++ b/Lib/test/test_macpath.py @@ -48,7 +48,7 @@ class MacPathTestCase(unittest.TestCase): splitext = macpath.splitext self.assertEquals(splitext(":foo.ext"), (':foo', '.ext')) self.assertEquals(splitext("foo:foo.ext"), ('foo:foo', '.ext')) - self.assertEquals(splitext(".ext"), ('', '.ext')) + self.assertEquals(splitext(".ext"), ('.ext', '')) self.assertEquals(splitext("foo.ext:foo"), ('foo.ext:foo', '')) self.assertEquals(splitext(":foo.ext:"), (':foo.ext:', '')) self.assertEquals(splitext(""), ('', '')) diff --git a/Lib/test/test_ntpath.py b/Lib/test/test_ntpath.py index 6bc2a05..da80bc6 100644 --- a/Lib/test/test_ntpath.py +++ b/Lib/test/test_ntpath.py @@ -18,13 +18,14 @@ def tester(fn, wantResult): tester('ntpath.splitext("foo.ext")', ('foo', '.ext')) tester('ntpath.splitext("/foo/foo.ext")', ('/foo/foo', '.ext')) -tester('ntpath.splitext(".ext")', ('', '.ext')) +tester('ntpath.splitext(".ext")', ('.ext', '')) tester('ntpath.splitext("\\foo.ext\\foo")', ('\\foo.ext\\foo', '')) tester('ntpath.splitext("foo.ext\\")', ('foo.ext\\', '')) tester('ntpath.splitext("")', ('', '')) tester('ntpath.splitext("foo.bar.ext")', ('foo.bar', '.ext')) tester('ntpath.splitext("xx/foo.bar.ext")', ('xx/foo.bar', '.ext')) tester('ntpath.splitext("xx\\foo.bar.ext")', ('xx\\foo.bar', '.ext')) +tester('ntpath.splitext("c:a/b\\c.d")', ('c:a/b\\c', '.d')) tester('ntpath.splitdrive("c:\\foo\\bar")', ('c:', '\\foo\\bar')) diff --git a/Lib/test/test_posixpath.py b/Lib/test/test_posixpath.py index 20a1fc5..d34c7e2 100644 --- a/Lib/test/test_posixpath.py +++ b/Lib/test/test_posixpath.py @@ -43,15 +43,27 @@ class PosixPathTest(unittest.TestCase): self.assertRaises(TypeError, posixpath.split) - def test_splitext(self): - self.assertEqual(posixpath.splitext("foo.ext"), ("foo", ".ext")) - self.assertEqual(posixpath.splitext("/foo/foo.ext"), ("/foo/foo", ".ext")) - self.assertEqual(posixpath.splitext(".ext"), ("", ".ext")) - self.assertEqual(posixpath.splitext("/foo.ext/foo"), ("/foo.ext/foo", "")) - self.assertEqual(posixpath.splitext("foo.ext/"), ("foo.ext/", "")) - self.assertEqual(posixpath.splitext(""), ("", "")) - self.assertEqual(posixpath.splitext("foo.bar.ext"), ("foo.bar", ".ext")) + def splitextTest(self, path, filename, ext): + self.assertEqual(posixpath.splitext(path), (filename, ext)) + self.assertEqual(posixpath.splitext("/" + path), ("/" + filename, ext)) + self.assertEqual(posixpath.splitext("abc/" + path), ("abc/" + filename, ext)) + self.assertEqual(posixpath.splitext("abc.def/" + path), ("abc.def/" + filename, ext)) + self.assertEqual(posixpath.splitext("/abc.def/" + path), ("/abc.def/" + filename, ext)) + self.assertEqual(posixpath.splitext(path + "/"), (filename + ext + "/", "")) + def test_splitext(self): + self.splitextTest("foo.bar", "foo", ".bar") + self.splitextTest("foo.boo.bar", "foo.boo", ".bar") + self.splitextTest("foo.boo.biff.bar", "foo.boo.biff", ".bar") + self.splitextTest(".csh.rc", ".csh", ".rc") + self.splitextTest("nodots", "nodots", "") + self.splitextTest(".cshrc", ".cshrc", "") + self.splitextTest("...manydots", "...manydots", "") + self.splitextTest("...manydots.ext", "...manydots", ".ext") + self.splitextTest(".", ".", "") + self.splitextTest("..", "..", "") + self.splitextTest("........", "........", "") + self.splitextTest("", "", "") self.assertRaises(TypeError, posixpath.splitext) def test_isabs(self): |