diff --git a/Lib/test/test_nturl2path.py b/Lib/test/test_nturl2path.py index 1bd77efd99ef4f..28e550f4b357a5 100644 --- a/Lib/test/test_nturl2path.py +++ b/Lib/test/test_nturl2path.py @@ -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:') diff --git a/Lib/test/test_urllib.py b/Lib/test/test_urllib.py index d26e35a24632ae..b8ef50e8f6c339 100644 --- a/Lib/test/test_urllib.py +++ b/Lib/test/test_urllib.py @@ -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) @@ -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\\') @@ -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') @@ -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)