mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
bpo-41939: Fix test_site.test_license_exists_at_url() (GH-22559) (#22567)
Call urllib.request.urlcleanup() to reset the global
urllib.request._opener.
(cherry picked from commit 1fce240d6c
)
Co-authored-by: Victor Stinner <vstinner@python.org>
This commit is contained in:
parent
1691435fe7
commit
10b4136bfa
2 changed files with 5 additions and 0 deletions
|
@ -509,6 +509,8 @@ class ImportSideEffectTests(unittest.TestCase):
|
|||
# string displayed by license in the absence of a LICENSE file.
|
||||
url = license._Printer__data.split()[1]
|
||||
req = urllib.request.Request(url, method='HEAD')
|
||||
# Reset global urllib.request._opener
|
||||
self.addCleanup(urllib.request.urlcleanup)
|
||||
try:
|
||||
with socket_helper.transient_internet(url):
|
||||
with urllib.request.urlopen(req) as data:
|
||||
|
|
|
@ -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.
|
Loading…
Add table
Add a link
Reference in a new issue