Skip to content

Commit

Permalink
Windows test fixes python#5
Browse files Browse the repository at this point in the history
  • Loading branch information
barneygale committed Oct 29, 2024
1 parent d4befde commit 1ff26c0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Lib/test/test_urllib.py
Original file line number Diff line number Diff line change
Expand Up @@ -1575,11 +1575,11 @@ 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')
self.assertEqual(fn('/////server/path/to/file'), '\\\\\\server\\path\\to\\file')
self.assertEqual(fn('/////server/path/to/file'), '\\\\server\\path\\to\\file')
# Localhost paths
self.assertEqual(fn('//localhost/C:/path/to/file'), 'C:\\path\\to\\file')
self.assertEqual(fn('//localhost/C|/path/to/file'), 'C:\\path\\to\\file')
Expand Down
4 changes: 2 additions & 2 deletions Lib/urllib/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -1654,7 +1654,7 @@ def url2pathname(url):
"""Convert the percent-encoded URL *url* to a local pathname."""
scheme, authority, path = urlsplit(url, scheme='file')[:3]
if scheme != 'file':
raise URLError(f'URI does not use "file" scheme: {url!r}')
raise URLError(f'URL {url!r} uses non-`file` scheme {scheme!r}')
if os.name == 'nt':
path = unquote(path)
if authority and authority != 'localhost':
Expand All @@ -1673,7 +1673,7 @@ def url2pathname(url):
path = path.replace('/', '\\')
else:
if not _is_local_host(authority):
raise URLError(f'file URI not on local host: {url!r}')
raise URLError(f'URL {url!r} uses non-local authority {authority!r}')
path = unquote(path)
return path

Expand Down

0 comments on commit 1ff26c0

Please sign in to comment.