mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Issue 28022: Catch deprecation warning in test_httplib, reported by Martin Panter
This commit is contained in:
parent
02b3035bc3
commit
8d14abc800
1 changed files with 9 additions and 6 deletions
|
@ -1642,14 +1642,16 @@ class HTTPSTest(TestCase):
|
||||||
with self.assertRaises(ssl.CertificateError):
|
with self.assertRaises(ssl.CertificateError):
|
||||||
h.request('GET', '/')
|
h.request('GET', '/')
|
||||||
# Same with explicit check_hostname=True
|
# Same with explicit check_hostname=True
|
||||||
h = client.HTTPSConnection('localhost', server.port, context=context,
|
with support.check_warnings(('', DeprecationWarning)):
|
||||||
check_hostname=True)
|
h = client.HTTPSConnection('localhost', server.port,
|
||||||
|
context=context, check_hostname=True)
|
||||||
with self.assertRaises(ssl.CertificateError):
|
with self.assertRaises(ssl.CertificateError):
|
||||||
h.request('GET', '/')
|
h.request('GET', '/')
|
||||||
# With check_hostname=False, the mismatching is ignored
|
# With check_hostname=False, the mismatching is ignored
|
||||||
context.check_hostname = False
|
context.check_hostname = False
|
||||||
h = client.HTTPSConnection('localhost', server.port, context=context,
|
with support.check_warnings(('', DeprecationWarning)):
|
||||||
check_hostname=False)
|
h = client.HTTPSConnection('localhost', server.port,
|
||||||
|
context=context, check_hostname=False)
|
||||||
h.request('GET', '/nonexistent')
|
h.request('GET', '/nonexistent')
|
||||||
resp = h.getresponse()
|
resp = h.getresponse()
|
||||||
resp.close()
|
resp.close()
|
||||||
|
@ -1666,8 +1668,9 @@ class HTTPSTest(TestCase):
|
||||||
h.close()
|
h.close()
|
||||||
# Passing check_hostname to HTTPSConnection should override the
|
# Passing check_hostname to HTTPSConnection should override the
|
||||||
# context's setting.
|
# context's setting.
|
||||||
h = client.HTTPSConnection('localhost', server.port, context=context,
|
with support.check_warnings(('', DeprecationWarning)):
|
||||||
check_hostname=True)
|
h = client.HTTPSConnection('localhost', server.port,
|
||||||
|
context=context, check_hostname=True)
|
||||||
with self.assertRaises(ssl.CertificateError):
|
with self.assertRaises(ssl.CertificateError):
|
||||||
h.request('GET', '/')
|
h.request('GET', '/')
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue