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.
This commit is contained in:
Victor Stinner 2019-07-02 14:50:19 +02:00 committed by GitHub
parent 039fb49c18
commit 7cb9204ee1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 62 additions and 0 deletions

View file

@ -447,6 +447,9 @@ class TestUrlopen(unittest.TestCase):
def setUp(self):
super(TestUrlopen, self).setUp()
# clear _opener global variable
self.addCleanup(urllib.request.urlcleanup)
# Ignore proxies for localhost tests.
def restore_environ(old_environ):
os.environ.clear()