summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCollin Winter <collinw@gmail.com>2007-03-23 22:24:39 +0000
committerCollin Winter <collinw@gmail.com>2007-03-23 22:24:39 +0000
commit75c7eb4fd85fa7a57d481d37a527aafabc540e12 (patch)
tree090dd05ccae878064979a7549f6d01a798d368d9
parent14553b08a1f93bb4ec8f8c2239ef240f634cc2da (diff)
downloadcpython-git-75c7eb4fd85fa7a57d481d37a527aafabc540e12.tar.gz
Make test_relpath() pass on Windows.
-rw-r--r--Lib/test/test_posixpath.py22
1 files changed, 13 insertions, 9 deletions
diff --git a/Lib/test/test_posixpath.py b/Lib/test/test_posixpath.py
index e2adb3422d..0abf4646c4 100644
--- a/Lib/test/test_posixpath.py
+++ b/Lib/test/test_posixpath.py
@@ -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)