Skip to content

Commit 3d5da04

Browse files
committed
Move cryptography-based imports into the fixture
Move the imports that require cryptography into the cert_factory fixture. This makes it possible to deselect these tests on systems where cryptography cannot be installed.
1 parent c6037c7 commit 3d5da04

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

news/10686.feature.rst

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Make it possible to deselect tests requiring cryptography package on systems
2+
where it cannot be installed.

tests/conftest.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
from pip._internal.locations import _USE_SYSCONFIG
2828
from pip._internal.utils.temp_dir import global_tempdir_manager
2929
from tests.lib import DATA_DIR, SRC_DIR, PipTestEnvironment, TestData
30-
from tests.lib.certs import make_tls_cert, serialize_cert, serialize_key
3130
from tests.lib.path import Path
3231
from tests.lib.server import MockServer as _MockServer
3332
from tests.lib.server import make_mock_server, server_running
@@ -551,6 +550,11 @@ def deprecated_python() -> bool:
551550

552551
@pytest.fixture(scope="session")
553552
def cert_factory(tmpdir_factory: pytest.TempdirFactory) -> CertFactory:
553+
# Delay the import requiring cryptography in order to make it possible
554+
# to deselect relevant tests on systems where cryptography cannot
555+
# be installed.
556+
from tests.lib.certs import make_tls_cert, serialize_cert, serialize_key
557+
554558
def factory() -> str:
555559
"""Returns path to cert/key file."""
556560
output_path = Path(str(tmpdir_factory.mktemp("certs"))) / "cert.pem"

0 commit comments

Comments
 (0)