MCPcopy Create free account
hub / github.com/pytest-dev/pytest / test_fixture_arg_ordering

Function test_fixture_arg_ordering

testing/python/fixtures.py:4422–4454  ·  view source on GitHub ↗

This test describes how fixtures in the same scope but without explicit dependencies between them are created. While users should make dependencies explicit, often they rely on this order, so this test exists to catch regressions in this regard. See #6540 and #6492.

(pytester: Pytester)

Source from the content-addressed store, hash-verified

4420
4421
4422def test_fixture_arg_ordering(pytester: Pytester) -> None:
4423 """
4424 This test describes how fixtures in the same scope but without explicit dependencies
4425 between them are created. While users should make dependencies explicit, often
4426 they rely on this order, so this test exists to catch regressions in this regard.
4427 See #6540 and #6492.
4428 """
4429 p1 = pytester.makepyfile(
4430 """
4431 import pytest
4432
4433 suffixes = []
4434
4435 @pytest.fixture
4436 def fix_1(): suffixes.append("fix_1")
4437 @pytest.fixture
4438 def fix_2(): suffixes.append("fix_2")
4439 @pytest.fixture
4440 def fix_3(): suffixes.append("fix_3")
4441 @pytest.fixture
4442 def fix_4(): suffixes.append("fix_4")
4443 @pytest.fixture
4444 def fix_5(): suffixes.append("fix_5")
4445
4446 @pytest.fixture
4447 def fix_combined(fix_1, fix_2, fix_3, fix_4, fix_5): pass
4448
4449 def test_suffix(fix_combined):
4450 assert suffixes == ["fix_1", "fix_2", "fix_3", "fix_4", "fix_5"]
4451 """
4452 )
4453 result = pytester.runpytest("-vv", str(p1))
4454 assert result.ret == 0
4455
4456
4457def test_yield_fixture_with_no_value(pytester: Pytester) -> None:

Callers

nothing calls this directly

Calls 2

makepyfileMethod · 0.45
runpytestMethod · 0.45

Tested by

no test coverage detected