summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_logging.py
diff options
context:
space:
mode:
authorVinay Sajip <vinay_sajip@yahoo.co.uk>2011-05-21 15:46:41 (GMT)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>2011-05-21 15:46:41 (GMT)
commit39e3528bb2f203ad3a32b4e5f7185056dccb778b (patch)
tree8f6b6a4705d715f52815b03dba375f4175cdd1b3 /Lib/test/test_logging.py
parent4bdd9f36a0c1ad8ec0cb95f3a4e014df1e6046a4 (diff)
downloadcpython-39e3528bb2f203ad3a32b4e5f7185056dccb778b.zip
cpython-39e3528bb2f203ad3a32b4e5f7185056dccb778b.tar.gz
cpython-39e3528bb2f203ad3a32b4e5f7185056dccb778b.tar.bz2
Issue #12136: Added change to handle non-availability of the ssl module.
Diffstat (limited to 'Lib/test/test_logging.py')
-rw-r--r--Lib/test/test_logging.py23
1 files changed, 14 insertions, 9 deletions
diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py
index c1684ee..496575a 100644
--- a/Lib/test/test_logging.py
+++ b/Lib/test/test_logging.py
@@ -1526,14 +1526,17 @@ IRbTpvlHWPjsSvHz0ZOH
for secure in (False, True):
addr = ('localhost', 0)
if secure:
- import ssl
- fd, fn = tempfile.mkstemp()
- os.close(fd)
- with open(fn, 'w') as f:
- f.write(self.PEMFILE)
- sslctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
- sslctx.load_cert_chain(fn)
- os.unlink(fn)
+ try:
+ import ssl
+ fd, fn = tempfile.mkstemp()
+ os.close(fd)
+ with open(fn, 'w') as f:
+ f.write(self.PEMFILE)
+ sslctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
+ sslctx.load_cert_chain(fn)
+ os.unlink(fn)
+ except ImportError:
+ sslctx = None
else:
sslctx = None
self.server = server = TestHTTPServer(addr, self.handle_request,
@@ -1541,7 +1544,9 @@ IRbTpvlHWPjsSvHz0ZOH
server.start()
server.ready.wait()
host = 'localhost:%d' % server.server_port
- self.h_hdlr = logging.handlers.HTTPHandler(host, '/frob', secure=secure)
+ secure_client = secure and sslctx
+ self.h_hdlr = logging.handlers.HTTPHandler(host, '/frob',
+ secure=secure_client)
self.log_data = None
root_logger.addHandler(self.h_hdlr)