Test Overview
This test uses a parametrized fixture in pytest to run the same test with multiple input values. It verifies that the input number is even.
This test uses a parametrized fixture in pytest to run the same test with multiple input values. It verifies that the input number is even.
import pytest @pytest.fixture(params=[2, 4, 6]) def even_number(request): return request.param def test_is_even(even_number): assert even_number % 2 == 0, f"{even_number} is not even"
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts | pytest test runner initialized | - | PASS |
| 2 | pytest collects test_is_even and sees it uses fixture even_number with params [2,4,6] | Test collection complete with 3 test cases generated | - | PASS |
| 3 | pytest runs test_is_even with even_number=2 | Test function receives even_number=2 | assert 2 % 2 == 0 | PASS |
| 4 | pytest runs test_is_even with even_number=4 | Test function receives even_number=4 | assert 4 % 2 == 0 | PASS |
| 5 | pytest runs test_is_even with even_number=6 | Test function receives even_number=6 | assert 6 % 2 == 0 | PASS |
| 6 | All parametrized tests passed | Test report shows 3 passed tests | - | PASS |