summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_httplib.py
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2014-12-07 18:41:52 (GMT)
committerBenjamin Peterson <benjamin@python.org>2014-12-07 18:41:52 (GMT)
commit204a0eca5af9c329c51ac3ab3a02e66f0b1b5e6f (patch)
treef1ee4b8cc7c29de901c359e92991b5a2fc716e52 /Lib/test/test_httplib.py
parent542125e6140e8a62911bbcf0b0465e9d56d37ec8 (diff)
parent227f6e0dc5415cac4dcec0c8b045d128b6b02915 (diff)
downloadcpython-204a0eca5af9c329c51ac3ab3a02e66f0b1b5e6f.zip
cpython-204a0eca5af9c329c51ac3ab3a02e66f0b1b5e6f.tar.gz
cpython-204a0eca5af9c329c51ac3ab3a02e66f0b1b5e6f.tar.bz2
merge 2.7.9 release branch
Diffstat (limited to 'Lib/test/test_httplib.py')
-rw-r--r--Lib/test/test_httplib.py13
1 files changed, 5 insertions, 8 deletions
diff --git a/Lib/test/test_httplib.py b/Lib/test/test_httplib.py
index a73a28b..011609b 100644
--- a/Lib/test/test_httplib.py
+++ b/Lib/test/test_httplib.py
@@ -639,18 +639,15 @@ class HTTPSTest(TestCase):
server = self.make_server(CERT_fakehostname)
context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
context.verify_mode = ssl.CERT_REQUIRED
+ context.check_hostname = True
context.load_verify_locations(CERT_fakehostname)
h = httplib.HTTPSConnection('localhost', server.port, context=context)
with self.assertRaises(ssl.CertificateError):
h.request('GET', '/')
- # Same with explicit check_hostname=True
- h = httplib.HTTPSConnection('localhost', server.port, context=context,
- check_hostname=True)
- with self.assertRaises(ssl.CertificateError):
- h.request('GET', '/')
- # With check_hostname=False, the mismatching is ignored
- h = httplib.HTTPSConnection('localhost', server.port, context=context,
- check_hostname=False)
+ h.close()
+ # With context.check_hostname=False, the mismatching is ignored
+ context.check_hostname = False
+ h = httplib.HTTPSConnection('localhost', server.port, context=context)
h.request('GET', '/nonexistent')
resp = h.getresponse()
self.assertEqual(resp.status, 404)