The easiest way to control the order in which fixtures are executed, is to just request the previous fixture in the later fixture. So to make sure b
runs before a
:
@pytest.fixture(autouse=True, scope="function")
def b():
pass
@pytest.fixture(scope="function")
def a(b):
pass
For details on the general fixture resolution order, see Maxim’s excellent answer below or have a look at the documentation.