Test Overview
This test uses a shared fixture defined in conftest.py to provide a sample user dictionary. It verifies that the test function receives the correct data from the fixture.
This test uses a shared fixture defined in conftest.py to provide a sample user dictionary. It verifies that the test function receives the correct data from the fixture.
import pytest # conftest.py @pytest.fixture def sample_user(): return {"name": "Alice", "age": 30} # test_user.py def test_user_name(sample_user): assert sample_user["name"] == "Alice"
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | PyTest discovers the fixture 'sample_user' in conftest.py | PyTest test runner ready to run tests in test_user.py | - | PASS |
| 2 | PyTest starts test 'test_user_name' and injects 'sample_user' fixture | Test function receives dictionary {"name": "Alice", "age": 30} | - | PASS |
| 3 | Test asserts that sample_user["name"] equals "Alice" | sample_user["name"] is "Alice" | assert sample_user["name"] == "Alice" | PASS |
| 4 | Test completes successfully | Test runner marks test as passed | - | PASS |