summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Panter <vadmium+py@gmail.com>2016-08-12 12:04:27 (GMT)
committerMartin Panter <vadmium+py@gmail.com>2016-08-12 12:04:27 (GMT)
commit51ad4cfad338bb26183424112757ca108f2f4222 (patch)
tree7049c91b1da22b915510ef5f2cce67c3bcce8edc
parent1b8f26c2ed6a360356285b1ff95d6cdd18e3276c (diff)
parent3cf0b2515ba8cfc855ac9a56a0b4545372157176 (diff)
downloadcpython-51ad4cfad338bb26183424112757ca108f2f4222.zip
cpython-51ad4cfad338bb26183424112757ca108f2f4222.tar.gz
cpython-51ad4cfad338bb26183424112757ca108f2f4222.tar.bz2
Issue #26741: Merge ResourceWarning fixes from 3.5
-rw-r--r--Lib/test/test_httplib.py12
-rw-r--r--Lib/test/test_poll.py3
2 files changed, 13 insertions, 2 deletions
diff --git a/Lib/test/test_httplib.py b/Lib/test/test_httplib.py
index 329f068..f45e352 100644
--- a/Lib/test/test_httplib.py
+++ b/Lib/test/test_httplib.py
@@ -1402,6 +1402,7 @@ class HTTPSTest(TestCase):
resp = h.getresponse()
h.close()
self.assertIn('nginx', resp.getheader('server'))
+ resp.close()
@support.system_must_validate_cert
def test_networked_trusted_by_default_cert(self):
@@ -1412,6 +1413,7 @@ class HTTPSTest(TestCase):
h.request('GET', '/')
resp = h.getresponse()
content_type = resp.getheader('content-type')
+ resp.close()
h.close()
self.assertIn('text/html', content_type)
@@ -1427,6 +1429,7 @@ class HTTPSTest(TestCase):
h.request('GET', '/')
resp = h.getresponse()
server_string = resp.getheader('server')
+ resp.close()
h.close()
self.assertIn('nginx', server_string)
@@ -1460,8 +1463,10 @@ class HTTPSTest(TestCase):
context.verify_mode = ssl.CERT_REQUIRED
context.load_verify_locations(CERT_localhost)
h = client.HTTPSConnection('localhost', server.port, context=context)
+ self.addCleanup(h.close)
h.request('GET', '/nonexistent')
resp = h.getresponse()
+ self.addCleanup(resp.close)
self.assertEqual(resp.status, 404)
def test_local_bad_hostname(self):
@@ -1486,13 +1491,18 @@ class HTTPSTest(TestCase):
check_hostname=False)
h.request('GET', '/nonexistent')
resp = h.getresponse()
+ resp.close()
+ h.close()
self.assertEqual(resp.status, 404)
# The context's check_hostname setting is used if one isn't passed to
# HTTPSConnection.
context.check_hostname = False
h = client.HTTPSConnection('localhost', server.port, context=context)
h.request('GET', '/nonexistent')
- self.assertEqual(h.getresponse().status, 404)
+ resp = h.getresponse()
+ self.assertEqual(resp.status, 404)
+ resp.close()
+ h.close()
# Passing check_hostname to HTTPSConnection should override the
# context's setting.
h = client.HTTPSConnection('localhost', server.port, context=context,
diff --git a/Lib/test/test_poll.py b/Lib/test/test_poll.py
index a0a332b..6a2bf6e 100644
--- a/Lib/test/test_poll.py
+++ b/Lib/test/test_poll.py
@@ -125,6 +125,8 @@ class PollTests(unittest.TestCase):
cmd = 'for i in 0 1 2 3 4 5 6 7 8 9; do echo testing...; sleep 1; done'
proc = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE,
bufsize=0)
+ proc.__enter__()
+ self.addCleanup(proc.__exit__, None, None, None)
p = proc.stdout
pollster = select.poll()
pollster.register( p, select.POLLIN )
@@ -147,7 +149,6 @@ class PollTests(unittest.TestCase):
continue
else:
self.fail('Unexpected return value from select.poll: %s' % fdlist)
- p.close()
def test_poll3(self):
# test int overflow