Test Overview
This test demonstrates how one pytest fixture can use another fixture as a dependency. It verifies that the dependent fixture correctly receives and uses the data from the base fixture.
This test demonstrates how one pytest fixture can use another fixture as a dependency. It verifies that the dependent fixture correctly receives and uses the data from the base fixture.
import pytest @pytest.fixture def base_data(): return 10 @pytest.fixture def dependent_data(base_data): return base_data * 2 def test_dependent_fixture(dependent_data): assert dependent_data == 20
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts | pytest test runner initialized | - | PASS |
| 2 | pytest discovers test_dependent_fixture and its fixture dependencies | Test function and fixtures recognized | - | PASS |
| 3 | pytest calls base_data fixture | base_data fixture returns 10 | - | PASS |
| 4 | pytest calls dependent_data fixture with base_data=10 | dependent_data fixture returns 20 | - | PASS |
| 5 | pytest runs test_dependent_fixture with dependent_data=20 | Test function executes assertion | assert dependent_data == 20 | PASS |
| 6 | Test ends | All assertions passed | - | PASS |