From: Miss Skeleton (bot) <31488909+miss-islington@users.noreply.github.com> Date: Tue, 6 Oct 2020 07:03:27 +0000 (-0700) Subject: bpo-41939: Fix test_site.test_license_exists_at_url() (GH-22559) X-Git-Tag: v3.8.7rc1~130 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=78bddc7794a629614dc84e195b9117416ae97ed3;p=thirdparty%2FPython%2Fcpython.git bpo-41939: Fix test_site.test_license_exists_at_url() (GH-22559) Call urllib.request.urlcleanup() to reset the global urllib.request._opener. (cherry picked from commit 1fce240d6c4b2b2cc17a86e88c65169e15b9feeb) Co-authored-by: Victor Stinner --- diff --git a/Lib/test/test_site.py b/Lib/test/test_site.py index 01008656bdd7..b95c108771d8 100644 --- a/Lib/test/test_site.py +++ b/Lib/test/test_site.py @@ -501,6 +501,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 test.support.transient_internet(url): with urllib.request.urlopen(req) as data: diff --git a/Misc/NEWS.d/next/Tests/2020-10-05-09-37-43.bpo-41939.P4OlbA.rst b/Misc/NEWS.d/next/Tests/2020-10-05-09-37-43.bpo-41939.P4OlbA.rst new file mode 100644 index 000000000000..e58ad2616da1 --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2020-10-05-09-37-43.bpo-41939.P4OlbA.rst @@ -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.