Test Overview
This test uses pytest to run the same test function with different inputs. It uses ids to give each test case a clear name. The test checks if the input number is even.
This test uses pytest to run the same test function with different inputs. It uses ids to give each test case a clear name. The test checks if the input number is even.
import pytest @pytest.mark.parametrize( "number,expected", [ (2, True), (3, False), (10, True), (7, False) ], ids=["two", "three", "ten", "seven"] ) def test_is_even(number, expected): assert (number % 2 == 0) == expected
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts with pytest runner | pytest ready to run tests | - | PASS |
| 2 | pytest collects test_is_even with 4 parameter sets and IDs | Test cases named: test_is_even[two], test_is_even[three], test_is_even[ten], test_is_even[seven] | - | PASS |
| 3 | pytest runs test_is_even with number=2, expected=True | Running test_is_even[two] | Check if 2 % 2 == 0 equals True | PASS |
| 4 | pytest runs test_is_even with number=3, expected=False | Running test_is_even[three] | Check if 3 % 2 == 0 equals False | PASS |
| 5 | pytest runs test_is_even with number=10, expected=True | Running test_is_even[ten] | Check if 10 % 2 == 0 equals True | PASS |
| 6 | pytest runs test_is_even with number=7, expected=False | Running test_is_even[seven] | Check if 7 % 2 == 0 equals False | PASS |
| 7 | All parameterized tests complete | All tests passed with clear IDs | - | PASS |