@pytest.mark.parametrize runs a test with several argument sets
Answer: pytest can parametrize tests at several levels. @pytest.mark.parametrize defines multiple sets of arguments (and fixtures) on a test function or class. pytest.fixture can also be parametrized. pytest_generate_tests is the hook for a custom scheme. The builtin decorator parametrizes the arguments of a test function: each tuple in the list becomes one test case.
See also
Claims
- id: C1 claim: pytest can parametrize tests at several levels. source: S1 evidence: "pytest enables test parametrization at several levels:"
- id: C2 claim: The parametrize mark defines multiple argument sets. source: S1 evidence: "allows one to define multiple sets of"
- id: C3 claim: The builtin decorator parametrizes test function arguments. source: S1 evidence: "decorator enables parametrization of arguments for a test function."
- id: C4 claim: The source parses parametrize marks in _parse_parametrize_args. source: S2 evidence: "def _parse_parametrize_args("
Sources
- [S1] How to parametrize fixtures and test functions. pytest docs. https://docs.pytest.org/en/stable/how-to/parametrize.html . License: MIT. Accessed 2026-11-16.
- [S2] pytest mark structures (source). pytest-dev/pytest (GitHub). https://github.com/pytest-dev/pytest/blob/main/src/_pytest/mark/structures.py . License: MIT. Accessed 2026-11-16.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: pytest docs, How to parametrize fixtures and test functions, MIT (https://raw.githubusercontent.com/pytest-dev/pytest/main/LICENSE); pytest-dev/pytest (GitHub), pytest mark structures (source), MIT (https://raw.githubusercontent.com/pytest-dev/pytest/main/LICENSE). Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: pytest docs, How to parametrize fixtures and test functions, MIT (https://raw.githubusercontent.com/pytest-dev/pytest/main/LICENSE); pytest-dev/pytest (GitHub), pytest mark structures (source), MIT (https://raw.githubusercontent.com/pytest-dev/pytest/main/LICENSE).
Cite this
iinventedlight. 2026. "@pytest.mark.parametrize runs a test with several argument sets." iinventedlight Library, iil:note:5e9ydx5z, version of 2026-11-16. https://iinventedlight.com/library/notes/pytest-parametrize/. License: CC-BY-4.0.
@misc{iil_note_5e9ydx5z,
author = {{iinventedlight}},
title = {{@pytest.mark.parametrize runs a test with several argument sets}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-16},
url = {https://iinventedlight.com/library/notes/pytest-parametrize/},
note = {Permanent ID iil:note:5e9ydx5z. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/pytest-parametrize.md.