Test Overview
This test uses a lazy fixture to provide test data only when needed. It verifies that the lazy fixture correctly supplies the expected value during test execution.
This test uses a lazy fixture to provide test data only when needed. It verifies that the lazy fixture correctly supplies the expected value during test execution.
import pytest @pytest.fixture def data(): print("Setup data fixture") return 42 @pytest.mark.parametrize('lazy_fixture', [pytest.lazy_fixture('data')]) def test_lazy_fixture(lazy_fixture): assert lazy_fixture == 42
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test runner starts and collects tests | pytest collects test_lazy_fixture with lazy_fixture parameter | - | PASS |
| 2 | pytest invokes the 'data' fixture lazily when test_lazy_fixture runs | Fixture 'data' setup prints 'Setup data fixture' and returns 42 | - | PASS |
| 3 | test_lazy_fixture receives lazy_fixture value 42 and runs assertion | Inside test, lazy_fixture == 42 | assert lazy_fixture == 42 | PASS |
| 4 | Test completes successfully | Test passed with no errors | - | PASS |