Skip to content

Commit b4fd462

Browse files
committed
Fix test_file in test_urllib2 on Windows with a longer repo path
1 parent a247dd3 commit b4fd462

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Lib/test/test_urllib2.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -850,14 +850,16 @@ def test_file(self):
850850
self.assertEqual(headers["Last-modified"], modified)
851851
self.assertEqual(respurl, canonurl)
852852

853+
_, cwd = os.path.splitdrive(os.getcwd())
854+
cwd = cwd.replace("\\", "/")
853855
for url in [
854856
parsed._replace(netloc='localhost:80').geturl(),
855857
"file:///file_does_not_exist.txt",
856858
"file://not-a-local-host.com//dir/file.txt",
857859
"file://%s:80%s/%s" % (socket.gethostbyname('localhost'),
858-
os.getcwd(), TESTFN),
860+
cwd, TESTFN),
859861
"file://somerandomhost.ontheinternet.com%s/%s" %
860-
(os.getcwd(), TESTFN),
862+
(cwd, TESTFN),
861863
]:
862864
try:
863865
f = open(TESTFN, "wb")

0 commit comments

Comments
 (0)