]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-41939: Fix test_site.test_license_exists_at_url() (#22559)
authorVictor Stinner <vstinner@python.org>
Mon, 5 Oct 2020 16:24:00 +0000 (18:24 +0200)
committerGitHub <noreply@github.com>
Mon, 5 Oct 2020 16:24:00 +0000 (18:24 +0200)
Call urllib.request.urlcleanup() to reset the global
urllib.request._opener.

Lib/test/test_site.py
Misc/NEWS.d/next/Tests/2020-10-05-09-37-43.bpo-41939.P4OlbA.rst [new file with mode: 0644]

index d3ee68facdbc3defcde106ae5fd49e3f38922387..a475ed1ab4c469a9ccb24487915c243e7c0aa49b 100644 (file)
@@ -525,6 +525,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:
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 (file)
index 0000000..e58ad26
--- /dev/null
@@ -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.