AI engineering glossary · Python advanced
What is parametrized test?
Parametrized test (also called pytest.mark.parametrize): A test written once and run repeatedly with different input and expected-output pairs. In pytest it uses @pytest.mark.parametrize, reducing duplicated tests and covering edge cases neatly. Each combination is reported as its own test result.
Parametrized test: an example
@pytest.mark.parametrize('x,y', [(1, 2), (5, 6)]) def test_inc(x, y): assert inc(x) == y runs twice.