Test Overview
This test uses pytest's parametrize decorator with a condition to run different inputs. It verifies the function returns expected results only for allowed inputs.
This test uses pytest's parametrize decorator with a condition to run different inputs. It verifies the function returns expected results only for allowed inputs.
import pytest def is_even(n): return n % 2 == 0 # Parametrize only even numbers @pytest.mark.parametrize('num', [n for n in [2, 3, 4, 5] if n % 2 == 0]) def test_is_even(num): assert is_even(num) is True
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts | pytest test runner initialized | - | PASS |
| 2 | pytest collects test_is_even with parametrize values filtered to even numbers [2, 4] | Test cases ready for num=2 and num=4 | - | PASS |
| 3 | Test runs test_is_even with num=2 | Function is_even called with 2 | assert is_even(2) is True | PASS |
| 4 | Test runs test_is_even with num=4 | Function is_even called with 4 | assert is_even(4) is True | PASS |
| 5 | Test ends with all parameterized cases passed | Test report shows 2 passed tests | - | PASS |