Skip to content

Commit

Permalink
Skip cryptography-based tests when it is unavailable
Browse files Browse the repository at this point in the history
Since the new versions of cryptography require Rust, it is no longer
possible to reliably install them on systems missing Rust support.
Given that only small subset of tests require certificates, skip them
when cryptography is unavailable.
  • Loading branch information
mgorny committed Nov 26, 2021
1 parent c6037c7 commit 8e5dc4b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
from pip._internal.locations import _USE_SYSCONFIG
from pip._internal.utils.temp_dir import global_tempdir_manager
from tests.lib import DATA_DIR, SRC_DIR, PipTestEnvironment, TestData
from tests.lib.certs import make_tls_cert, serialize_cert, serialize_key
from tests.lib.path import Path
from tests.lib.server import MockServer as _MockServer
from tests.lib.server import make_mock_server, server_running
Expand Down Expand Up @@ -551,6 +550,11 @@ def deprecated_python() -> bool:

@pytest.fixture(scope="session")
def cert_factory(tmpdir_factory: pytest.TempdirFactory) -> CertFactory:
try:
from tests.lib.certs import make_tls_cert, serialize_cert, serialize_key
except ImportError:
pytest.skip("Cryptography is not available")

def factory() -> str:
"""Returns path to cert/key file."""
output_path = Path(str(tmpdir_factory.mktemp("certs"))) / "cert.pem"
Expand Down

0 comments on commit 8e5dc4b

Please sign in to comment.