Skip to content

Order of execution of fixtures #3596

Closed
Closed
@LexLootor

Description

@LexLootor

In version of pytest 3.5.0 appeared execution of fixtures by higher scope. #3306

But I need to use autouse fixture with scope=function first, at least before fixtures with other scope and without autouse. There are any possibilities to do this?

def test_1(fixture_module):
    assert True

@pytest.fixture(autouse=True, scope="function")
def fixture_function():
    print("scope function")

@pytest.fixture(scope="module")
def fixture_module():
    print("scope module")

Code output:

scope module
scope function

pytest version 3.6.0
On version 3.2.2 this example work in this order:

scope function
scope module

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: needs informationreporter needs to provide more information; can be closed after 2 or more weeks of inactivitytopic: fixturesanything involving fixtures directly or indirectlytype: questiongeneral question, might be closed after 2 weeks of inactivity

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions