summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSeth M. Larson <SethMichaelLarson@users.noreply.github.com>2018-04-24 09:21:58 -0500
committerGitHub <noreply@github.com>2018-04-24 09:21:58 -0500
commita1acbcfc41a3f55e58e0f240eedcdf6568de4850 (patch)
tree4d062c4109b2c068dd1fda3e7d0536f5f3a5ef6f
parentd16dab803ced786b6ed40327842330a645461bae (diff)
downloadurllib3-a1acbcfc41a3f55e58e0f240eedcdf6568de4850.tar.gz
Fix skip logic in SecureTransport tests
-rw-r--r--test/contrib/test_securetransport.py33
1 files changed, 20 insertions, 13 deletions
diff --git a/test/contrib/test_securetransport.py b/test/contrib/test_securetransport.py
index bd4ad592..f5e2cc4c 100644
--- a/test/contrib/test_securetransport.py
+++ b/test/contrib/test_securetransport.py
@@ -6,28 +6,35 @@ import ssl
import pytest
try:
- from urllib3.contrib.securetransport import (
- WrappedSocket, inject_into_urllib3, extract_from_urllib3
- )
-except ImportError as e:
- pytestmark = pytest.mark.skip('Could not import SecureTransport: %r' % e)
-
-from ..with_dummyserver.test_https import TestHTTPS, TestHTTPS_TLSv1 # noqa: F401
-from ..with_dummyserver.test_socketlevel import ( # noqa: F401
- TestSNI, TestSocketClosing, TestClientCerts
-)
+ from urllib3.contrib.securetransport import WrappedSocket
+except ImportError:
+ pass
def setup_module():
- inject_into_urllib3()
+ try:
+ from urllib3.contrib.securetransport import inject_into_urllib3
+ inject_into_urllib3()
+ except ImportError as e:
+ pytest.skip('Could not import SecureTransport: %r' % e)
def teardown_module():
- extract_from_urllib3()
+ try:
+ from urllib3.contrib.securetransport import extract_from_urllib3
+ extract_from_urllib3()
+ except ImportError:
+ pass
+
+
+from ..with_dummyserver.test_https import TestHTTPS, TestHTTPS_TLSv1 # noqa: F401
+from ..with_dummyserver.test_socketlevel import ( # noqa: F401
+ TestSNI, TestSocketClosing, TestClientCerts
+)
def test_no_crash_with_empty_trust_bundle():
with contextlib.closing(socket.socket()) as s:
ws = WrappedSocket(s)
with pytest.raises(ssl.SSLError):
- ws._custom_validate(True, b"")
+ws._custom_validate(True, b"")