mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
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:
parent
039fb49c18
commit
7cb9204ee1
9 changed files with 62 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue