Skip to content

Commit

Permalink
Windows test fixes python#1
Browse files Browse the repository at this point in the history
  • Loading branch information
barneygale committed Oct 29, 2024
1 parent fb92f42 commit 8086522
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Lib/test/test_nturl2path.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def test_pathname2url(self):
for url in urls:
self.assertEqual(fn(nturl2path.url2pathname(url)), url)

def test_url2pathname_win(self):
def test_url2pathname(self):
fn = nturl2path.url2pathname
self.assertEqual(fn('/C:/'), 'C:\\')
self.assertEqual(fn("///C|"), 'C:')
Expand Down
26 changes: 13 additions & 13 deletions Lib/test/test_urllib.py
Original file line number Diff line number Diff line change
Expand Up @@ -1523,26 +1523,26 @@ def test_quoting(self):
def test_pathname2url_win(self):
# Test special prefixes are correctly handled in pathname2url()
fn = urllib.request.pathname2url
self.assertEqual(fn('\\\\?\\C:\\dir'), '///C:/dir')
self.assertEqual(fn('\\\\?\\unc\\server\\share\\dir'), '/server/share/dir')
self.assertEqual(fn('\\\\?\\C:\\dir'), '//?/C:/dir')
self.assertEqual(fn('\\\\?\\unc\\server\\share\\dir'), '//?/unc/server/share/dir')
self.assertEqual(fn("C:"), '///C:')
self.assertEqual(fn("C:\\"), '///C:')
self.assertEqual(fn("C:\\"), '///C:/')
self.assertEqual(fn('C:\\a\\b.c'), '///C:/a/b.c')
self.assertEqual(fn('C:\\a\\b%#c'), '///C:/a/b%25%23c')
self.assertEqual(fn('C:\\a\\b\xe9'), '///C:/a/b%C3%A9')
self.assertEqual(fn('C:\\foo\\bar\\spam.foo'), "///C:/foo/bar/spam.foo")
# Long drive letter
self.assertRaises(IOError, fn, "XX:\\")
self.assertEqual(fn("XX:\\"), "file:XX:/")
# No drive letter
self.assertEqual(fn("\\folder\\test\\"), '/folder/test/')
self.assertEqual(fn("\\\\folder\\test\\"), '////folder/test/')
self.assertEqual(fn("\\\\\\folder\\test\\"), '/////folder/test/')
self.assertEqual(fn('\\\\some\\share\\'), '////some/share/')
self.assertEqual(fn('\\\\some\\share\\a\\b.c'), '////some/share/a/b.c')
self.assertEqual(fn('\\\\some\\share\\a\\b%#c\xe9'), '////some/share/a/b%25%23c%C3%A9')
self.assertEqual(fn("\\\\folder\\test\\"), '//folder/test/')
self.assertEqual(fn("\\\\\\folder\\test\\"), '///folder/test/')
self.assertEqual(fn('\\\\some\\share\\'), '//some/share/')
self.assertEqual(fn('\\\\some\\share\\a\\b.c'), '//some/share/a/b.c')
self.assertEqual(fn('\\\\some\\share\\a\\b%#c\xe9'), '//some/share/a/b%25%23c%C3%A9')
# Round-tripping
urls = ['///C:',
'/////folder/test/',
'//folder/test/',
'///C:/foo/bar/spam.foo']
for url in urls:
self.assertEqual(fn(urllib.request.url2pathname(url)), url)
Expand All @@ -1563,7 +1563,7 @@ def test_url2pathname_win(self):
self.assertEqual(fn("///C|"), 'C:')
self.assertEqual(fn("///C:"), 'C:')
self.assertEqual(fn('///C:/'), 'C:\\')
self.assertEqual(fn('/C|//'), 'C:\\')
self.assertEqual(fn('/C|//'), 'C:\\\\')
self.assertEqual(fn('///C|/path'), 'C:\\path')
# No DOS drive
self.assertEqual(fn("///C/test/"), '\\\\\\C\\test\\')
Expand All @@ -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.assertRaises(IOError, fn, "///\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 All @@ -1585,7 +1585,7 @@ def test_url2pathname_win(self):
self.assertEqual(fn('//localhost/C|/path/to/file'), 'C:\\path\\to\\file')
# Round-tripping
paths = ['C:',
r'\\\C\test\\',
r'\C\test\\',
r'C:\foo\bar\spam.foo']
for path in paths:
self.assertEqual(fn(urllib.request.pathname2url(path)), path)
Expand Down

0 comments on commit 8086522

Please sign in to comment.