Skip to content

Commit 192d3ad

Browse files
blueyednicoddemus
authored andcommitted
tests: add test_fixture_arg_ordering
This is a regression test for part of #6492, testing one of the fixes in #6551.
1 parent 38538c6 commit 192d3ad

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

testing/python/fixtures.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4207,3 +4207,38 @@ def test_bug(value):
42074207
)
42084208
result = testdir.runpytest()
42094209
result.assert_outcomes(passed=10)
4210+
4211+
4212+
def test_fixture_arg_ordering(testdir):
4213+
"""
4214+
This test describes how fixtures in the same scope but without explicit dependencies
4215+
between them are created. While users should make dependencies explicit, often
4216+
they rely on this order, so this test exists to catch regressions in this regard.
4217+
See #6540 and #6492.
4218+
"""
4219+
p1 = testdir.makepyfile(
4220+
"""
4221+
import pytest
4222+
4223+
suffixes = []
4224+
4225+
@pytest.fixture
4226+
def fix_1(): suffixes.append("fix_1")
4227+
@pytest.fixture
4228+
def fix_2(): suffixes.append("fix_2")
4229+
@pytest.fixture
4230+
def fix_3(): suffixes.append("fix_3")
4231+
@pytest.fixture
4232+
def fix_4(): suffixes.append("fix_4")
4233+
@pytest.fixture
4234+
def fix_5(): suffixes.append("fix_5")
4235+
4236+
@pytest.fixture
4237+
def fix_combined(fix_1, fix_2, fix_3, fix_4, fix_5): pass
4238+
4239+
def test_suffix(fix_combined):
4240+
assert suffixes == ["fix_1", "fix_2", "fix_3", "fix_4", "fix_5"]
4241+
"""
4242+
)
4243+
result = testdir.runpytest("-vv", str(p1))
4244+
assert result.ret == 0

0 commit comments

Comments
 (0)