pytest.mark.usefixtures has no effect on fixtures
Bad code:
import pytest
@pytest.fixture()
def a():
pass
@pytest.mark.usefixtures('a')
@pytest.fixture()
def b():
pass
Good code:
import pytest
@pytest.fixture()
def a():
pass
@pytest.fixture()
def b(a):
pass
- according to the pytest docs
on
pytest.mark.usefixtures
:Also note that this mark has no effect when applied to fixtures.
- pytest does not raise any error or warning when fixtures are decorated with
pytest.mark.usefixtures
, which can lead to incorrect results and broken tests