Closed micuda closed 3 years ago
Hi!
Try to use pytest_runtest_call
instead of pytest_runtest_setup
. Also you don't need pytest-lazy-fixture
, just use request.getfixturevalue
:
@dataclass
class TestItem:
...
@property
def current_environment(self):
try:
return self.item._request.getfixturevalue(for_all_envs.__name__)
except ValueError:
return None
...
@pytest.fixture(
autouse = True,
params = [
pytest.param(czech_environment.__name__, id = 'CZ'),
pytest.param(slovak_environment.__name__, id = 'SK'),
]
)
def for_all_envs(request):
return request.getfixturevalue(request.param)
Thanks @TvoroG,
pytest_runtest_call
does the work. =)
Hi all,
Each test are run once for all environment in our test suite by default.
conftest.py
and the usage below:
test.py
For now everything works well (output below):
Each environment needs custom setup and that's where the
pytest_lazyfixture
comes. I added two fixtures and changed parameter values offor_all_envs
fixture.conftest.py
and now the output is:
If the test is run for both env, everything is OK:
test.py
output
It seems there is missing
colitem <Function test_tests_skipping[sk]>
in theself.stack
in/home/jcas/.pyenv/versions/3.9.6/envs/pytest_lazy_fixture_bug3.9.6/lib/python3.9/site-packages/_pytest/runner.py:408
(from the last frame).I'm not sure what is wrong, because I don't know these
pytest
internals. Also I'm not sure if it is related topytest-lazy-fixture
.Can anybody help me with this please?