summaryrefslogtreecommitdiff
path: root/Lib/test/test_urllib2net.py
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2019-07-02 14:50:19 +0200
committerGitHub <noreply@github.com>2019-07-02 14:50:19 +0200
commit7cb9204ee1cf204f6f507d99a60f7c5bb359eebb (patch)
treeae351690ede26e65b690c5802de6aa0a850894ee /Lib/test/test_urllib2net.py
parent039fb49c185570ab7b02f13fbdc51c859cfd831e (diff)
downloadcpython-git-7cb9204ee1cf204f6f507d99a60f7c5bb359eebb.tar.gz
bpo-37421: urllib.request tests call urlcleanup() (GH-14529)
urllib.request tests now call urlcleanup() to remove temporary files created by urlretrieve() tests and to clear the _opener global variable set by urlopen() and functions calling indirectly urlopen(). regrtest now checks if urllib.request._url_tempfiles and urllib.request._opener are changed by tests.
Diffstat (limited to 'Lib/test/test_urllib2net.py')
-rw-r--r--Lib/test/test_urllib2net.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/test/test_urllib2net.py b/Lib/test/test_urllib2net.py
index 0f43d71ea6..040a2ce276 100644
--- a/Lib/test/test_urllib2net.py
+++ b/Lib/test/test_urllib2net.py
@@ -82,6 +82,9 @@ class AuthTests(unittest.TestCase):
class CloseSocketTest(unittest.TestCase):
def test_close(self):
+ # clear _opener global variable
+ self.addCleanup(urllib.request.urlcleanup)
+
# calling .close() on urllib2's response objects should close the
# underlying socket
url = support.TEST_HTTP_URL
@@ -257,6 +260,10 @@ class OtherNetworkTests(unittest.TestCase):
class TimeoutTest(unittest.TestCase):
+ def setUp(self):
+ # clear _opener global variable
+ self.addCleanup(urllib.request.urlcleanup)
+
def test_http_basic(self):
self.assertIsNone(socket.getdefaulttimeout())
url = support.TEST_HTTP_URL