From f3192dac669ce14016efcec267ef331108d6b442 Mon Sep 17 00:00:00 2001 From: Barney Gale Date: Tue, 15 Apr 2025 19:16:34 +0100 Subject: GH-90812: Add test for `urlopen()` of file URI for UNC path (#132489) --- Lib/test/test_urllib.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Lib/test/test_urllib.py b/Lib/test/test_urllib.py index da3db2f..90de828 100644 --- a/Lib/test/test_urllib.py +++ b/Lib/test/test_urllib.py @@ -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): -- cgit v0.12