Skip to content

Commit 1fce240

Browse files
authored
bpo-41939: Fix test_site.test_license_exists_at_url() (#22559)
Call urllib.request.urlcleanup() to reset the global urllib.request._opener.
1 parent 060937d commit 1fce240

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

Lib/test/test_site.py

+2
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,8 @@ def test_license_exists_at_url(self):
525525
# string displayed by license in the absence of a LICENSE file.
526526
url = license._Printer__data.split()[1]
527527
req = urllib.request.Request(url, method='HEAD')
528+
# Reset global urllib.request._opener
529+
self.addCleanup(urllib.request.urlcleanup)
528530
try:
529531
with socket_helper.transient_internet(url):
530532
with urllib.request.urlopen(req) as data:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Fix test_site.test_license_exists_at_url(): call
2+
``urllib.request.urlcleanup()`` to reset the global
3+
``urllib.request._opener``. Patch by Victor Stinner.

0 commit comments

Comments
 (0)