summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_logging.py
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2014-11-24 02:36:44 (GMT)
committerBenjamin Peterson <benjamin@python.org>2014-11-24 02:36:44 (GMT)
commit43052a14c1412893ae76253f1323a41769d09b07 (patch)
tree1e7b9b2ecdfb9f54fb2830f17bf9dc902771ed2b /Lib/test/test_logging.py
parentf200498abe02aaeb451f115d828e938f2f366891 (diff)
downloadcpython-43052a14c1412893ae76253f1323a41769d09b07.zip
cpython-43052a14c1412893ae76253f1323a41769d09b07.tar.gz
cpython-43052a14c1412893ae76253f1323a41769d09b07.tar.bz2
add context parameter to HTTPHandler (closes #22788)
Diffstat (limited to 'Lib/test/test_logging.py')
-rw-r--r--Lib/test/test_logging.py19
1 files changed, 5 insertions, 14 deletions
diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py
index ba790d1..5729678 100644
--- a/Lib/test/test_logging.py
+++ b/Lib/test/test_logging.py
@@ -1667,21 +1667,11 @@ class HTTPHandlerTest(BaseTest):
localhost_cert = os.path.join(here, "keycert.pem")
sslctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
sslctx.load_cert_chain(localhost_cert)
- # Unfortunately, HTTPHandler doesn't allow us to change the
- # SSLContext used by HTTPSConnection, so we have to
- # monkeypatch. This can be cleaned up if issue 22788 is
- # fixed.
- old = ssl._create_default_https_context
- def restore_handler():
- ssl._create_default_https_context = old
- self.addCleanup(restore_handler)
- def hack_create_ctx():
- ctx = old()
- ctx.load_verify_locations(localhost_cert)
- return ctx
- ssl._create_default_https_context = hack_create_ctx
+
+ context = ssl.create_default_context(cafile=localhost_cert)
else:
sslctx = None
+ context = None
self.server = server = TestHTTPServer(addr, self.handle_request,
0.01, sslctx=sslctx)
server.start()
@@ -1689,7 +1679,8 @@ class HTTPHandlerTest(BaseTest):
host = 'localhost:%d' % server.server_port
secure_client = secure and sslctx
self.h_hdlr = logging.handlers.HTTPHandler(host, '/frob',
- secure=secure_client)
+ secure=secure_client,
+ context=context)
self.log_data = None
root_logger.addHandler(self.h_hdlr)