bpo-41939: Fix test_site.test_license_exists_at_url() (#22559)

Call urllib.request.urlcleanup() to reset the global
urllib.request._opener.
This commit is contained in:
Victor Stinner 2020-10-05 18:24:00 +02:00 committed by GitHub
parent 060937da98
commit 1fce240d6c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 0 deletions

View File

@ -525,6 +525,8 @@ class ImportSideEffectTests(unittest.TestCase):
# string displayed by license in the absence of a LICENSE file. # string displayed by license in the absence of a LICENSE file.
url = license._Printer__data.split()[1] url = license._Printer__data.split()[1]
req = urllib.request.Request(url, method='HEAD') req = urllib.request.Request(url, method='HEAD')
# Reset global urllib.request._opener
self.addCleanup(urllib.request.urlcleanup)
try: try:
with socket_helper.transient_internet(url): with socket_helper.transient_internet(url):
with urllib.request.urlopen(req) as data: with urllib.request.urlopen(req) as data:

View File

@ -0,0 +1,3 @@
Fix test_site.test_license_exists_at_url(): call
``urllib.request.urlcleanup()`` to reset the global
``urllib.request._opener``. Patch by Victor Stinner.