From 133050c4ba5f0f60a4389257355c84966afce77c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lum=C3=ADr=20=27Frenzy=27=20Balhar?= Date: Wed, 17 Mar 2021 19:50:32 +0100 Subject: [PATCH] Fix pip_cert pytest fixture (#2083) pip_cert is recognized as a generator so it should not use return if PIP_CERT is in os.environ. Fixes: https://github.com/pypa/virtualenv/issues/2048 --- tests/conftest.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 9beaa12b3..e4766ab99 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -153,14 +153,15 @@ def pip_cert(tmp_path_factory): # workaround for https://github.com/pypa/pip/issues/8984 - if the certificate is explicitly set no error can happen key = ensure_str("PIP_CERT") if key in os.environ: - return - cert = tmp_path_factory.mktemp("folder") / "cert" - import pkgutil - - cert_data = pkgutil.get_data("pip._vendor.certifi", "cacert.pem") - cert.write_bytes(cert_data) - with change_os_environ(key, str(cert)): yield + else: + cert = tmp_path_factory.mktemp("folder") / "cert" + import pkgutil + + cert_data = pkgutil.get_data("pip._vendor.certifi", "cacert.pem") + cert.write_bytes(cert_data) + with change_os_environ(key, str(cert)): + yield @pytest.fixture(autouse=True)