Skip to content

Commit 7418faf

Browse files
committed
Add regression test for pytest-dev#2405
1 parent 1d240ce commit 7418faf

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

testing/acceptance_test.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -964,3 +964,27 @@ def test2():
964964
""")
965965
result = testdir.runpytest()
966966
result.stdout.fnmatch_lines(['* 2 passed *'])
967+
968+
969+
def test_fixture_order_respects_scope(testdir):
970+
"""Ensure that fixtures are created according to scope order, regression test for #2405
971+
"""
972+
testdir.makepyfile('''
973+
import pytest
974+
975+
data = {}
976+
977+
@pytest.fixture(scope='module')
978+
def clean_data():
979+
data.clear()
980+
981+
@pytest.fixture(autouse=True)
982+
def add_data():
983+
data.update(value=True)
984+
985+
@pytest.mark.usefixtures('clean_data')
986+
def test_value():
987+
assert data.get('value')
988+
''')
989+
result = testdir.runpytest()
990+
assert result.ret == 0

0 commit comments

Comments
 (0)