Skip to content

Commit

Permalink
bpo-41939: Fix test_site.test_license_exists_at_url() (GH-22559) (#22567
Browse files Browse the repository at this point in the history
)

Call urllib.request.urlcleanup() to reset the global
urllib.request._opener.
(cherry picked from commit 1fce240)

Co-authored-by: Victor Stinner <vstinner@python.org>
  • Loading branch information
miss-islington and vstinner authored Oct 5, 2020
1 parent 1691435 commit 10b4136
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Lib/test/test_site.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,8 @@ def test_license_exists_at_url(self):
# 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:
Expand Down
Original file line number Diff line number Diff line change
@@ -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.

0 comments on commit 10b4136

Please sign in to comment.