commit:     2f13337ce5da0e1990bbdf82158f75e497001a27
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Fri Nov 26 15:20:33 2021 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sat Nov 27 10:27:24 2021 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=2f13337c

dev-python/pip: Skip cryptography tests when not available

Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 .../pip/files/pip-21.3.1-cryptography-tests.patch  | 39 ++++++++++++++++++++++
 dev-python/pip/pip-21.3.1-r1.ebuild                | 10 ++++++
 2 files changed, 49 insertions(+)

diff --git a/dev-python/pip/files/pip-21.3.1-cryptography-tests.patch 
b/dev-python/pip/files/pip-21.3.1-cryptography-tests.patch
new file mode 100644
index 000000000000..1505d487ad40
--- /dev/null
+++ b/dev-python/pip/files/pip-21.3.1-cryptography-tests.patch
@@ -0,0 +1,39 @@
+From 8fa5d719a3c902ca9b6c9198229b7a67fecf8b8e Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgo...@gentoo.org>
+Date: Fri, 26 Nov 2021 16:12:16 +0100
+Subject: [PATCH] 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.
+---
+ tests/conftest.py | 6 +++++-
+ 1 file changed, 5 insertions(+), 1 deletion(-)
+
+diff --git a/tests/conftest.py b/tests/conftest.py
+index 076aeaf19..bab6ab3f5 100644
+--- a/tests/conftest.py
++++ b/tests/conftest.py
+@@ -27,7 +27,6 @@ from pip._internal.cli.main import main as pip_entry_point
+ 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
+@@ -535,6 +534,11 @@ def deprecated_python() -> bool:
+ 
+ @pytest.fixture(scope="session")
+ def cert_factory(tmpdir_factory: pytest.TempdirFactory) -> Callable[[], str]:
++    # Delay the import requiring cryptography in order to make it possible
++    # to deselect relevant tests on systems where cryptography cannot
++    # be installed.
++    from tests.lib.certs import make_tls_cert, serialize_cert, serialize_key
++
+     def factory() -> str:
+         """Returns path to cert/key file."""
+         output_path = Path(str(tmpdir_factory.mktemp("certs"))) / "cert.pem"
+-- 
+2.34.1
+

diff --git a/dev-python/pip/pip-21.3.1-r1.ebuild 
b/dev-python/pip/pip-21.3.1-r1.ebuild
index 2b3d17d2f6de..37cf7af8a3d9 100644
--- a/dev-python/pip/pip-21.3.1-r1.ebuild
+++ b/dev-python/pip/pip-21.3.1-r1.ebuild
@@ -57,6 +57,7 @@ BDEPEND="
 python_prepare_all() {
        local PATCHES=(
                "${FILESDIR}/${PN}-21.3-no-coverage.patch"
+               "${FILESDIR}/${P}-cryptography-tests.patch"
        )
        if ! use vanilla; then
                PATCHES+=( 
"${FILESDIR}/pip-20.0.2-disable-system-install.patch" )
@@ -97,6 +98,15 @@ python_test() {
                
tests/functional/test_warning.py::test_pip_works_with_warnings_as_errors
        )
 
+       if ! has_version "dev-python/cryptography[${PYTHON_USEDEP}]"; then
+               EPYTEST_DESELECT+=(
+                       
tests/functional/test_install.py::test_install_sends_client_cert
+                       
tests/functional/test_install_config.py::test_do_not_prompt_for_authentication
+                       
tests/functional/test_install_config.py::test_prompt_for_authentication
+                       
tests/functional/test_install_config.py::test_prompt_for_keyring_if_needed
+               )
+       fi
+
        distutils_install_for_testing
        pushd "${WORKDIR}/virtualenv-${VENV_PV}" >/dev/null || die
        distutils_install_for_testing

Reply via email to