summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_posixpath.py
diff options
context:
space:
mode:
authorHirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>2010-10-18 12:13:18 (GMT)
committerHirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>2010-10-18 12:13:18 (GMT)
commitb08820ad406b9fd291a8707e4bad41cc8486ab08 (patch)
tree4d9ef9284fb34d3e4b0e7bf7a29b60e7d952c433 /Lib/test/test_posixpath.py
parent08654e18eed3c8b0224100fe270da618d60d6eb5 (diff)
downloadcpython-b08820ad406b9fd291a8707e4bad41cc8486ab08.zip
cpython-b08820ad406b9fd291a8707e4bad41cc8486ab08.tar.gz
cpython-b08820ad406b9fd291a8707e4bad41cc8486ab08.tar.bz2
Issue #5117: Case normalization was needed on ntpath.relpath(). And
fixed root directory issue on posixpath.relpath(). (Ported working fixes from ntpath)
Diffstat (limited to 'Lib/test/test_posixpath.py')
-rw-r--r--Lib/test/test_posixpath.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/test/test_posixpath.py b/Lib/test/test_posixpath.py
index fd71ac9..8cac0df 100644
--- a/Lib/test/test_posixpath.py
+++ b/Lib/test/test_posixpath.py
@@ -394,6 +394,15 @@ class PosixPathTest(unittest.TestCase):
"../"+curdir+"/a/b")
self.assertEqual(posixpath.relpath("a", "b/c"), "../../a")
self.assertEqual(posixpath.relpath("a", "a"), ".")
+ self.assertEqual(posixpath.relpath("/foo/bar/bat", "/x/y/z"), '../../../foo/bar/bat')
+ self.assertEqual(posixpath.relpath("/foo/bar/bat", "/foo/bar"), 'bat')
+ self.assertEqual(posixpath.relpath("/foo/bar/bat", "/"), 'foo/bar/bat')
+ self.assertEqual(posixpath.relpath("/", "/foo/bar/bat"), '../../..')
+ self.assertEqual(posixpath.relpath("/foo/bar/bat", "/x"), '../foo/bar/bat')
+ self.assertEqual(posixpath.relpath("/x", "/foo/bar/bat"), '../../../x')
+ self.assertEqual(posixpath.relpath("/", "/"), '.')
+ self.assertEqual(posixpath.relpath("/a", "/a"), '.')
+ self.assertEqual(posixpath.relpath("/a/b", "/a/b"), '.')
finally:
os.getcwd = real_getcwd
@@ -412,6 +421,15 @@ class PosixPathTest(unittest.TestCase):
b"../"+curdir+b"/a/b")
self.assertEqual(posixpath.relpath(b"a", b"b/c"), b"../../a")
self.assertEqual(posixpath.relpath(b"a", b"a"), b".")
+ self.assertEqual(posixpath.relpath(b"/foo/bar/bat", b"/x/y/z"), b'../../../foo/bar/bat')
+ self.assertEqual(posixpath.relpath(b"/foo/bar/bat", b"/foo/bar"), b'bat')
+ self.assertEqual(posixpath.relpath(b"/foo/bar/bat", b"/"), b'foo/bar/bat')
+ self.assertEqual(posixpath.relpath(b"/", b"/foo/bar/bat"), b'../../..')
+ self.assertEqual(posixpath.relpath(b"/foo/bar/bat", b"/x"), b'../foo/bar/bat')
+ self.assertEqual(posixpath.relpath(b"/x", b"/foo/bar/bat"), b'../../../x')
+ self.assertEqual(posixpath.relpath(b"/", b"/"), b'.')
+ self.assertEqual(posixpath.relpath(b"/a", b"/a"), b'.')
+ self.assertEqual(posixpath.relpath(b"/a/b", b"/a/b"), b'.')
self.assertRaises(TypeError, posixpath.relpath, b"bytes", "str")
self.assertRaises(TypeError, posixpath.relpath, "str", b"bytes")