Skip to content

Commit 133050c

Browse files
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: #2048
1 parent bb446cb commit 133050c

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

tests/conftest.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -153,14 +153,15 @@ def pip_cert(tmp_path_factory):
153153
# workaround for https://github.com/pypa/pip/issues/8984 - if the certificate is explicitly set no error can happen
154154
key = ensure_str("PIP_CERT")
155155
if key in os.environ:
156-
return
157-
cert = tmp_path_factory.mktemp("folder") / "cert"
158-
import pkgutil
159-
160-
cert_data = pkgutil.get_data("pip._vendor.certifi", "cacert.pem")
161-
cert.write_bytes(cert_data)
162-
with change_os_environ(key, str(cert)):
163156
yield
157+
else:
158+
cert = tmp_path_factory.mktemp("folder") / "cert"
159+
import pkgutil
160+
161+
cert_data = pkgutil.get_data("pip._vendor.certifi", "cacert.pem")
162+
cert.write_bytes(cert_data)
163+
with change_os_environ(key, str(cert)):
164+
yield
164165

165166

166167
@pytest.fixture(autouse=True)

0 commit comments

Comments
 (0)