-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Labels
Description
The new fixture pip_cert
implemented in bc787b2 does not work if PIP_CERT
is in os.environ. Pytest expect it to yield a value because it's recognized as a generator but if PIP_CERT
is present in os.environ, the fixture returns None
which causes pytest to fail with:
fixturefunc = <function pip_cert at 0x7f14f12ef3a0>
request = <SubRequest 'pip_cert' for <Function test_python[no_prompt]>>
kwargs = {'tmp_path_factory': TempPathFactory(_given_basetemp=None, _trace=<pluggy._tracing.TagTracerSub object at 0x7f14f0197490>, _basetemp=PosixPath('/tmp/pytest-of-mockbuild/pytest-0'))}
def call_fixture_func(
fixturefunc: "_FixtureFunc[_FixtureValue]", request: FixtureRequest, kwargs
) -> _FixtureValue:
if is_generator(fixturefunc):
fixturefunc = cast(
Callable[..., Generator[_FixtureValue, None, None]], fixturefunc
)
generator = fixturefunc(**kwargs)
try:
fixture_result = next(generator)
except StopIteration:
> raise ValueError(
"{} did not yield a value".format(request.fixturename)
) from None
E ValueError: pip_cert did not yield a value
fixturefunc = <function pip_cert at 0x7f14f12ef3a0>
generator = <generator object pip_cert at 0x7f14ed790580>
kwargs = {'tmp_path_factory': TempPathFactory(_given_basetemp=None, _trace=<pluggy._tracing.TagTracerSub object at 0x7f14f0197490>, _basetemp=PosixPath('/tmp/pytest-of-mockbuild/pytest-0'))}
request = <SubRequest 'pip_cert' for <Function test_python[no_prompt]>>
/usr/lib/python3.9/site-packages/_pytest/fixtures.py:917: ValueError
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")
.