GH-90812: Add test for urlopen() of file URI for UNC path (#132489)

This commit is contained in:
Barney Gale 2025-04-15 19:16:34 +01:00 committed by GitHub
parent 666eeda13d
commit f3192dac66
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -181,6 +181,16 @@ class urlopen_FileTests(unittest.TestCase):
def test_relativelocalfile(self):
self.assertRaises(ValueError,urllib.request.urlopen,'./' + self.pathname)
def test_remote_authority(self):
# Test for GH-90812.
url = 'file://pythontest.net/foo/bar'
with self.assertRaises(urllib.error.URLError) as e:
urllib.request.urlopen(url)
if os.name == 'nt':
self.assertEqual(e.exception.filename, r'\\pythontest.net\foo\bar')
else:
self.assertEqual(e.exception.reason, 'file:// scheme is supported only on localhost')
class ProxyTests(unittest.TestCase):