-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pip_cert
fixture breaks tests if PIP_CERT
is in os.environ
#2048
Labels
Comments
What about changing the return to yield and moving the rest of the function to an else branch? Lines 151 to 163 in a4025d6
@pytest.fixture(autouse=True, scope="session")
def pip_cert(tmp_path_factory):
# workaround for https:/pypa/pip/issues/8984 - if the certificate is explicitly set no error can happen
key = ensure_str("PIP_CERT")
if key in os.environ:
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 |
Would it be helpful to prepare a PR with the proposed change? |
Yes. |
On it. |
frenzymadness
added a commit
to frenzymadness/virtualenv
that referenced
this issue
Mar 17, 2021
pip_cert is recognized as a generator so it should not use return if PIP_CERT is in os.environ. Fixes: pypa#2048
gaborbernat
pushed a commit
that referenced
this issue
Mar 17, 2021
pip_cert is recognized as a generator so it should not use return if PIP_CERT is in os.environ. Fixes: #2048
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The new fixture
pip_cert
implemented in bc787b2 does not work ifPIP_CERT
is in os.environ. Pytest expect it to yield a value because it's recognized as a generator but ifPIP_CERT
is present in os.environ, the fixture returnsNone
which causes pytest to fail with:An easy fix might be to use the condition in the decorator like
@pytest.fixture(autouse=ensure_str("PIP_CERT") not in os.environ, scope="session")
.The text was updated successfully, but these errors were encountered: