[Python-checkins] cpython (merge 3.4 -> default): Issue #7665: Fixed tests test_ntpath and test_urllib2 when ran in the
serhiy.storchaka
python-checkins at python.org
Mon Jan 26 09:28:18 CET 2015
https://hg.python.org/cpython/rev/1db1cd711104
changeset: 94294:1db1cd711104
parent: 94291:9b0b6804528d
parent: 94293:04fa56628830
user: Serhiy Storchaka <storchaka at gmail.com>
date: Mon Jan 26 10:26:29 2015 +0200
summary:
Issue #7665: Fixed tests test_ntpath and test_urllib2 when ran in the
directory containing a backslash.
files:
Lib/test/test_ntpath.py | 7 ++++---
Lib/test/test_urllib2.py | 2 +-
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/Lib/test/test_ntpath.py b/Lib/test/test_ntpath.py
--- a/Lib/test/test_ntpath.py
+++ b/Lib/test/test_ntpath.py
@@ -306,13 +306,14 @@
self.skipTest('nt module not available')
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 support.temp_cwd(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("c:/foo/bar/bat", "c:/x/y")', '..\\..\\foo\\bar\\bat')
tester('ntpath.relpath("//conky/mountpoint/a", "//conky/mountpoint/b/c")', '..\\..\\a')
diff --git a/Lib/test/test_urllib2.py b/Lib/test/test_urllib2.py
--- a/Lib/test/test_urllib2.py
+++ b/Lib/test/test_urllib2.py
@@ -44,7 +44,7 @@
self.assertRaises(ValueError, urllib.request.urlopen, 'bogus url')
# XXX Name hacking to get this to work on Windows.
- fname = os.path.abspath(urllib.request.__file__).replace('\\', '/')
+ fname = os.path.abspath(urllib.request.__file__).replace(os.sep, '/')
if os.name == 'nt':
file_url = "file:///%s" % fname
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list