Adding parameterized fixture in pytest_generate_test is not executing the fixture's code, even if it is marked as "indirect" #12216
Labels
topic: fixtures
anything involving fixtures directly or indirectly
topic: parametrize
related to @pytest.mark.parametrize
Using pytest 8.1.1, I'm trying to add a parameterized fixture to a test during pytest_generate_tests. While it's possible to do so when the test is expecting a parameter with the fixture name, trying to add a "usefixtures" mark in order to invoke an undeclared fixture, does not.
Minimal reproduction:
In this form, the code results in collection error, claiming
In test_me: function uses no fixture 'myfix'
If the commented out line is uncommented, which, according to @RonnyPfannschmidt shouldn't be done), the test is running and looks as if it's parameterized (even without the "usefixtures" part) , but the fixture's code is not invoked.
Other attempts I've tried are described here: #12205 (reply in thread)
There should be a way to conditionally add a fixture to a test, and according to some older discussions, it has been the case in the past
The text was updated successfully, but these errors were encountered: