GH-84850: Remove urllib.request.URLopener and FancyURLopener (#125739)

This commit is contained in:
Barney Gale 2024-11-19 14:01:49 +00:00 committed by GitHub
parent a99dd23c1f
commit 4d771977b1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 44 additions and 987 deletions

View file

@ -5,6 +5,7 @@ from test.support import socket_helper
import contextlib
import socket
import urllib.error
import urllib.parse
import urllib.request
import os
@ -101,13 +102,10 @@ class urlopenNetworkTests(unittest.TestCase):
# test getcode() with the fancy opener to get 404 error codes
URL = self.url + "XXXinvalidXXX"
with socket_helper.transient_internet(URL):
with self.assertWarns(DeprecationWarning):
open_url = urllib.request.FancyURLopener().open(URL)
try:
code = open_url.getcode()
finally:
open_url.close()
self.assertEqual(code, 404)
with self.assertRaises(urllib.error.URLError) as e:
with urllib.request.urlopen(URL):
pass
self.assertEqual(e.exception.code, 404)
@support.requires_resource('walltime')
def test_bad_address(self):