Skip to content

Commit

Permalink
Fix pip_cert pytest fixture (#2083)
Browse files Browse the repository at this point in the history
pip_cert is recognized as a generator so it should not use
return if PIP_CERT is in os.environ.

Fixes: #2048
  • Loading branch information
frenzymadness authored Mar 17, 2021
1 parent bb446cb commit 133050c
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 133050c

Please sign in to comment.