PY-TEST0018 · module_generated_parametrization_count
Count parametrizations driven by a module-generated case collection.
This is a deterministic rule for python. Read its implementation.
Definition
Section titled “Definition”Find a collected test whose pytest.mark.parametrize case source is a module-level list, set,
or generator comprehension. Unlike a short literal table, its item count grows with repository
data and silently multiplies the collected suite. Report each generated parametrization once.
Evidence
Section titled “Evidence”Each finding points to the test and counts the generated parametrization decorators it carries. The value is their sum per module. This rule measures the unbounded collection mechanism rather than guessing a case count from source text.
Exceptions
Section titled “Exceptions”Literal case tables, static ranges, fixture parametrization, and dynamically returned iterables abstain. Keep a generated parametrization only when every case needs its own selection identity, marks, retry history, or parallel scheduling. Repository-wide structural invariants should normally aggregate their failures inside one test.
Examples
Section titled “Examples”Bad
Parametrizing one invariant over every discovered `rule module` is reported.
GoodParametrizing three named protocol modes from a literal tuple is not.
References
Section titled “References”- Cites “pytest documentation”, parametrization. Open reference
- Cites “xUnit Test Patterns”, test code duplication