(original) (raw)

changeset: 94292:1e12c9e5bc89 branch: 2.7 parent: 94207:2db41d551a4f user: Serhiy Storchaka storchaka@gmail.com date: Mon Jan 26 10:26:00 2015 +0200 files: Lib/test/test_ntpath.py Lib/test/test_urllib2.py description: Issue #7665: Fixed tests test_ntpath and test_urllib2 when ran in the directory containing a backslash. diff -r 2db41d551a4f -r 1e12c9e5bc89 Lib/test/test_ntpath.py --- a/Lib/test/test_ntpath.py Sun Jan 18 11:42:50 2015 +0200 +++ b/Lib/test/test_ntpath.py Mon Jan 26 10:26:00 2015 +0200 @@ -281,13 +281,14 @@ 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")', '.') diff -r 2db41d551a4f -r 1e12c9e5bc89 Lib/test/test_urllib2.py --- a/Lib/test/test_urllib2.py Sun Jan 18 11:42:50 2015 +0200 +++ b/Lib/test/test_urllib2.py Mon Jan 26 10:26:00 2015 +0200 @@ -25,7 +25,7 @@ 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... /storchaka@gmail.com