with self.assertRaises(ssl.CertificateError):
h.request('GET', '/')
# Same with explicit check_hostname=True
- h = client.HTTPSConnection('localhost', server.port, context=context,
- check_hostname=True)
+ with support.check_warnings(('', DeprecationWarning)):
+ h = client.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
context.check_hostname = False
- h = client.HTTPSConnection('localhost', server.port, context=context,
- check_hostname=False)
+ with support.check_warnings(('', DeprecationWarning)):
+ h = client.HTTPSConnection('localhost', server.port,
+ context=context, check_hostname=False)
h.request('GET', '/nonexistent')
resp = h.getresponse()
resp.close()
h.close()
# Passing check_hostname to HTTPSConnection should override the
# context's setting.
- h = client.HTTPSConnection('localhost', server.port, context=context,
- check_hostname=True)
+ with support.check_warnings(('', DeprecationWarning)):
+ h = client.HTTPSConnection('localhost', server.port,
+ context=context, check_hostname=True)
with self.assertRaises(ssl.CertificateError):
h.request('GET', '/')