Skip to content

Commit

Permalink
Windows test fixes python#6
Browse files Browse the repository at this point in the history
  • Loading branch information
barneygale committed Oct 29, 2024
1 parent 1ff26c0 commit 26db297
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Lib/test/test_urllib.py
Original file line number Diff line number Diff line change
Expand Up @@ -1575,7 +1575,7 @@ def test_url2pathname_win(self):
self.assertEqual(fn('///C|/path/to/file'), 'C:\\path\\to\\file')
self.assertEqual(fn("///C|/foo/bar/spam.foo"), 'C:\\foo\\bar\\spam.foo')
# Non-ASCII drive letter
self.assertEqual(fn("///\u00e8|/"), "u00e8:\\")
self.assertEqual(fn("///\u00e8|/"), "\u00e8:\\")
# UNC paths
self.assertEqual(fn('//server/path/to/file'), '\\\\server\\path\\to\\file')
self.assertEqual(fn('////server/path/to/file'), '\\\\server\\path\\to\\file')
Expand Down
15 changes: 8 additions & 7 deletions Lib/test/test_urllib2.py
Original file line number Diff line number Diff line change
Expand Up @@ -823,14 +823,15 @@ def test_file(self):
urls = [
"file://localhost%s" % urlpath,
"file://%s" % urlpath,
"file://%s%s" % (socket.gethostbyname('localhost'), urlpath),
]
try:
localaddr = socket.gethostbyname(socket.gethostname())
except socket.gaierror:
localaddr = ''
if localaddr:
urls.append("file://%s%s" % (localaddr, urlpath))
if os.name == 'nt':
urls.append("file://%s%s" % (socket.gethostbyname('localhost'), urlpath))
try:
localaddr = socket.gethostbyname(socket.gethostname())
except socket.gaierror:
localaddr = ''
if localaddr:
urls.append("file://%s%s" % (localaddr, urlpath))

for url in urls:
f = open(TESTFN, "wb")
Expand Down

0 comments on commit 26db297

Please sign in to comment.