Skip to content
This repository was archived by the owner on Jan 13, 2021. It is now read-only.

Commit 0cc874c

Browse files
committed
Make test conditional on import of SSLContext
1 parent 632125d commit 0cc874c

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

test/test_hyper_SSLContext.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
import os
66

77
from hyper.compat import ssl
8-
from hyper.ssl_compat import SSLContext
8+
try:
9+
from hyper.ssl_compat import SSLContext
10+
except ImportError:
11+
SSLContext = None
912

1013

1114
TEST_DIR = os.path.abspath(os.path.dirname(__file__))
@@ -20,14 +23,15 @@ class TestHyperSSLContext(object):
2023
"""
2124
def test_custom_context_with_cert_as_file(self):
2225
# Test using hyper's own SSLContext
23-
context = SSLContext(ssl.PROTOCOL_SSLv23)
24-
context.verify_mode = ssl.CERT_NONE
25-
context.check_hostname = False
26+
if SSLContext is not None:
27+
context = SSLContext(ssl.PROTOCOL_SSLv23)
28+
context.verify_mode = ssl.CERT_NONE
29+
context.check_hostname = False
2630

27-
# Test that we can load in a cert and key protected by a passphrase,
28-
# from files.
29-
context.load_cert_chain(
30-
certfile=CLIENT_CERT_FILE,
31-
keyfile=CLIENT_KEY_FILE,
32-
password='abc123'
33-
)
31+
# Test that we can load in a cert and key protected by a passphrase,
32+
# from files.
33+
context.load_cert_chain(
34+
certfile=CLIENT_CERT_FILE,
35+
keyfile=CLIENT_KEY_FILE,
36+
password='abc123'
37+
)

0 commit comments

Comments
 (0)