Skip to content

Commit 77c8bc4

Browse files
authored
tests: make the TLS tests skip when pyopenssl isn't available (#1873)
In some distributions e.g. yocto pyOpenSSL is a packageconfig and disabled by default, and it means pyopenssl.py module is not installed as a result. This test fails plainly when it can not find urllib3.contrib.pyopenssl instead skip the test if it does not find the module.
1 parent 0b9107d commit 77c8bc4

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

tests/transport/test__custom_tls_signer.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,16 @@
1818

1919
import pytest # type: ignore
2020
from requests.packages.urllib3.util.ssl_ import create_urllib3_context # type: ignore
21-
import urllib3.contrib.pyopenssl # type: ignore
2221

2322
from google.auth import exceptions
2423
from google.auth.transport import _custom_tls_signer
2524

26-
urllib3.contrib.pyopenssl.inject_into_urllib3()
25+
urllib3_pyopenssl = pytest.importorskip(
26+
"urllib3.contrib.pyopenssl",
27+
reason="urllib3.contrib.pyopenssl not available in this environment",
28+
)
29+
30+
urllib3_pyopenssl.inject_into_urllib3()
2731

2832
FAKE_ENTERPRISE_CERT_FILE_PATH = "/path/to/enterprise/cert/file"
2933
ENTERPRISE_CERT_FILE = os.path.join(

0 commit comments

Comments
 (0)