[Python-checkins] r54556 - python/trunk/Lib/test/test_posixpath.py

collin.winter python-checkins at python.org
Fri Mar 23 23:24:40 CET 2007


Author: collin.winter
Date: Fri Mar 23 23:24:39 2007
New Revision: 54556

Modified:
   python/trunk/Lib/test/test_posixpath.py
Log:
Make test_relpath() pass on Windows.

Modified: python/trunk/Lib/test/test_posixpath.py
==============================================================================
--- python/trunk/Lib/test/test_posixpath.py	(original)
+++ python/trunk/Lib/test/test_posixpath.py	Fri Mar 23 23:24:39 2007
@@ -480,15 +480,19 @@
                 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)


More information about the Python-checkins mailing list