parametrizing metafunc in pytest_generate_tests does not group tests as expected #6979
Labels
status: help wanted
developers would like help from experts on this topic
topic: fixtures
anything involving fixtures directly or indirectly
topic: parametrize
related to @pytest.mark.parametrize
type: bug
problem that needs to be addressed
conftest.py:
test file:
Since fw_config is session-scoped, I am hoping that the tests will run in the following order:
test_abc[ABC]
test_all[ABC]
test_def[DEF]
test_all[DEF]
And that fw_config will be called only twice.
However, instead, they are called in the following order:
test_abc[ABC]
test_def[DEF]
test_all[ABC]
test_all[DEF]
and fw_config is called four times.
I have been trying for almost a month to get this behavior using various methods and have not been able to achieve it.
I am aware that I can just have test_abc skip() if fw_config is 'DEF', but then I have a skipped test in my output. I want to not run the test at all.
fw_config here is a stand-in for an expensive configuration with a name. Some tests need to run on all configs, and some tests need to run on only a subset.
Is there any way to do this? Am I doing something incorrectly?
I am guessing that there are actually three instances of the fixture being created, and pytest is treating them as being totally separated.
The text was updated successfully, but these errors were encountered: