]> granicus.if.org Git - python/commitdiff
Issue #7665: Fixed tests test_ntpath and test_urllib2 when ran in the
authorSerhiy Storchaka <storchaka@gmail.com>
Mon, 26 Jan 2015 08:26:00 +0000 (10:26 +0200)
committerSerhiy Storchaka <storchaka@gmail.com>
Mon, 26 Jan 2015 08:26:00 +0000 (10:26 +0200)
directory containing a backslash.

Lib/test/test_ntpath.py
Lib/test/test_urllib2.py

index 7b5f7bb28c33a249b9e6e5850ecf42baaa1a96e8..0fbe6a17786aafa84d7c6d6632374b4d8c5eaa53 100644 (file)
@@ -281,13 +281,14 @@ class TestNtpath(unittest.TestCase):
             tester('ntpath.abspath("C:\\")', "C:\\")
 
     def test_relpath(self):
-        currentdir = os.path.split(os.getcwd())[-1]
         tester('ntpath.relpath("a")', 'a')
         tester('ntpath.relpath(os.path.abspath("a"))', 'a')
         tester('ntpath.relpath("a/b")', 'a\\b')
         tester('ntpath.relpath("../a/b")', '..\\a\\b')
-        tester('ntpath.relpath("a", "../b")', '..\\'+currentdir+'\\a')
-        tester('ntpath.relpath("a/b", "../c")', '..\\'+currentdir+'\\a\\b')
+        with test_support.temp_cwd(test_support.TESTFN) as cwd_dir:
+            currentdir = os.path.basename(cwd_dir)
+            tester('ntpath.relpath("a", "../b")', '..\\'+currentdir+'\\a')
+            tester('ntpath.relpath("a/b", "../c")', '..\\'+currentdir+'\\a\\b')
         tester('ntpath.relpath("a", "b/c")', '..\\..\\a')
         tester('ntpath.relpath("//conky/mountpoint/a", "//conky/mountpoint/b/c")', '..\\..\\a')
         tester('ntpath.relpath("a", "a")', '.')
index 5b2c7080e71915c7e4bccf19b29e9350f42bd43a..32ffd0acefb2e2a16227352e06f2ebca4e1ceb89 100644 (file)
@@ -25,7 +25,7 @@ class TrivialTests(unittest.TestCase):
         self.assertRaises(ValueError, urllib2.urlopen, 'bogus url')
 
         # XXX Name hacking to get this to work on Windows.
-        fname = os.path.abspath(urllib2.__file__).replace('\\', '/')
+        fname = os.path.abspath(urllib2.__file__).replace(os.sep, '/')
 
         # And more hacking to get it to work on MacOS. This assumes
         # urllib.pathname2url works, unfortunately...