Fix skip logic in SecureTransport tests
MODIFY
test/contrib/test_securetransport.py
test/contrib/test_securetransport.py
@@ -6,24 +6,31 @@ 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():
+ 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():
+ 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():

Fix skip logic in SecureTransport tests