Skip to content

Commit f3192da

Browse files
authored
GH-90812: Add test for urlopen() of file URI for UNC path (#132489)
1 parent 666eeda commit f3192da

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Lib/test/test_urllib.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,16 @@ def test_iter(self):
181181
def test_relativelocalfile(self):
182182
self.assertRaises(ValueError,urllib.request.urlopen,'./' + self.pathname)
183183

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

185195
class ProxyTests(unittest.TestCase):
186196

0 commit comments

Comments
 (0)