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

Function test_fixture_order_respects_scope

testing/acceptance_test.py:1083–1105  ·  view source on GitHub ↗

Ensure that fixtures are created according to scope order (#2405).

(pytester: Pytester)

Source from the content-addressed store, hash-verified

1081
1082
1083def test_fixture_order_respects_scope(pytester: Pytester) -> None:
1084 """Ensure that fixtures are created according to scope order (#2405)."""
1085 pytester.makepyfile(
1086 """
1087 import pytest
1088
1089 data = {}
1090
1091 @pytest.fixture(scope='module')
1092 def clean_data():
1093 data.clear()
1094
1095 @pytest.fixture(autouse=True)
1096 def add_data():
1097 data.update(value=True)
1098
1099 @pytest.mark.usefixtures('clean_data')
1100 def test_value():
1101 assert data.get('value')
1102 """
1103 )
1104 result = pytester.runpytest()
1105 assert result.ret == 0
1106
1107
1108def test_frame_leak_on_failing_test(pytester: Pytester) -> None:

Callers

nothing calls this directly

Calls 2

makepyfileMethod · 0.45
runpytestMethod · 0.45

Tested by

no test coverage detected