Skip to content

Commit d9e0939

Browse files
committed
GH-90812: Add test for urlopen() of file URI for UNC path
1 parent ccad61e commit d9e0939

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Lib/test/test_urllib.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,17 @@ def test_iter(self):
183183
def test_relativelocalfile(self):
184184
self.assertRaises(ValueError,urllib.request.urlopen,'./' + self.pathname)
185185

186+
def test_remote_authority(self):
187+
# Test for GH-90812.
188+
url = 'file://pythontest.net/foo/bar'
189+
with self.assertRaises(urllib.error.URLError) as e:
190+
urllib.request.urlopen(url)
191+
if os.name == 'nt':
192+
self.assertEqual(e.exception.reason, 'File not found')
193+
self.assertEqual(e.exception.filename, r'\\pythontest.net\foo\bar')
194+
else:
195+
self.assertEqual(e.exception.reason, 'file:// scheme is supported only on localhost')
196+
186197

187198
class ProxyTests(unittest.TestCase):
188199

0 commit comments

Comments
 (0)