]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Make test_relpath() pass on Windows.
authorCollin Winter <collinw@gmail.com>
Fri, 23 Mar 2007 22:24:39 +0000 (22:24 +0000)
committerCollin Winter <collinw@gmail.com>
Fri, 23 Mar 2007 22:24:39 +0000 (22:24 +0000)
Lib/test/test_posixpath.py

index e2adb3422d3f7dc83767fa02439d3e5cc2b54c89..0abf4646c450d2c38633ab2a86a11e9dc75d9bbc 100644 (file)
@@ -480,15 +480,19 @@ class PosixPathTest(unittest.TestCase):
                 safe_rmdir(ABSTFN)
 
     def test_relpath(self):
-        currentdir = os.path.split(os.getcwd())[-1]
-        self.assertRaises(ValueError, posixpath.relpath, "")
-        self.assertEqual(posixpath.relpath("a"), "a")
-        self.assertEqual(posixpath.relpath(os.path.abspath("a")), "a")
-        self.assertEqual(posixpath.relpath("a/b"), "a/b")
-        self.assertEqual(posixpath.relpath("../a/b"), "../a/b")
-        self.assertEqual(posixpath.relpath("a", "../b"), "../"+currentdir+"/a")
-        self.assertEqual(posixpath.relpath("a/b", "../c"), "../"+currentdir+"/a/b")
-        self.assertEqual(posixpath.relpath("a", "b/c"), "../../a")
+        (real_getcwd, os.getcwd) = (os.getcwd, lambda: r"/home/user/bar")
+        try:
+            curdir = os.path.split(os.getcwd())[-1]
+            self.assertRaises(ValueError, posixpath.relpath, "")
+            self.assertEqual(posixpath.relpath("a"), "a")
+            self.assertEqual(posixpath.relpath(posixpath.abspath("a")), "a")
+            self.assertEqual(posixpath.relpath("a/b"), "a/b")
+            self.assertEqual(posixpath.relpath("../a/b"), "../a/b")
+            self.assertEqual(posixpath.relpath("a", "../b"), "../"+curdir+"/a")
+            self.assertEqual(posixpath.relpath("a/b", "../c"), "../"+curdir+"/a/b")
+            self.assertEqual(posixpath.relpath("a", "b/c"), "../../a")
+        finally:
+            os.getcwd = real_getcwd
 
 def test_main():
     test_support.run_unittest(PosixPathTest)