Test Overview
This test uses a fixture factory to create user objects with different names. It verifies that the created user has the expected name.
This test uses a fixture factory to create user objects with different names. It verifies that the created user has the expected name.
import pytest @pytest.fixture def user_factory(): def create_user(name): return {"name": name} return create_user def test_user_creation(user_factory): user = user_factory("Alice") assert user["name"] == "Alice" user2 = user_factory("Bob") assert user2["name"] == "Bob"
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts | pytest test runner initialized | - | PASS |
| 2 | Fixture user_factory is called to get the factory function | user_factory fixture returns create_user function | - | PASS |
| 3 | test_user_creation calls user_factory("Alice") to create user | user dictionary {'name': 'Alice'} created | assert user["name"] == "Alice" | PASS |
| 4 | test_user_creation calls user_factory("Bob") to create another user | user dictionary {'name': 'Bob'} created | assert user2["name"] == "Bob" | PASS |
| 5 | Test ends successfully | All assertions passed | - | PASS |