Repository navigation
Cannot use pytest.mark.usefixtures() in pytest.param #4112
Description
Activity
linking #349 (comment) as it has some more details on the problem
- addedtype: bugproblem that needs to be addressedproblem that needs to be addressedtopic: parametrizerelated to @pytest.mark.parametrizerelated to @pytest.mark.parametrizetopic: fixturesanything involving fixtures directly or indirectlyanything involving fixtures directly or indirectly
on Oct 19, 2018 I think I have same problem. Specified fixture as argument for
pytest.mark.usefixturewill be ignored if this specified fixture hasparams.import pytest @pytest.fixture def data(): return dict() @pytest.fixture(params=[1, 2]) def add_data(request, data): data['a'] = request.param @pytest.mark.usefixtures('add_data') @pytest.fixture def completed_data(data): data['b'] = 3 return data def test_data(completed_data): assert 'a' in completed_data
I expect
add_datamust be executed before start completingcompleted_databut it does not.
Also it work (how am I expect) if specifyadd_datain define ofcompleted_data:@pytest.fixture def completed_data(data, add_data): data['b'] = 3 return data
Please say me if I'm wrong.
Reacted by Vi Miomarks on fixtures are NOT supported and won't be
- added a commit that references this issue
on Apr 10, 2020 linking #349 (comment) as it has some more details on the problem
Just for reference, here is the code @dtomas linked to in their original comment: https://github.com/pytest-dev/pytest/blob/3.9.0/src/_pytest/python.py#L418-L421
Posting this link here since @dtomas's original comment didn't pin the code link to a specific git version or hash. It now points to some unrelated code.
It looks like that there is still no support on adding
pytest.mark.usefixturestomarksofpytest.param. Are there any news on that?@DenisKuplyakov I'm not aware of anyone working on this. If there were any news, they would likely be in this issue.
Reacted by Denis KuplyakovHey guys, do we have any updates on it?
@vyahello see the comment right above yours. I'm not sure what you're trying to achieve by asking the same thing again a month later...
- added a commit that references this issue
on Oct 9, 2024 - added a commit that references this issue
on Jan 5, 2026
Adding Fixtures to a parametrization of a test function via
pytest.mark.usefixtureshas no effect. The fixtures are not executed and are missing fromrequest.fixturenames.Example: