This rule raises an issue when a test parameterization mechanism is configured with an empty collection as the source of test values.
In Python with pytest, this specifically occurs when using the @pytest.mark.parametrize decorator with an empty sequence (list, tuple,
or other iterable) as the values argument.
Passing an empty list to @pytest.mark.parametrize collects the test but skips it with got empty parameter set for (…).
The suite still passes while providing no coverage for that function.
When @pytest.mark.parametrize has no value sets to iterate over, the test is silently skipped during collection:
This situation typically occurs due to:
Unlike mistakes that cause failures, an empty parametrized test collection fails silently. The test won’t raise an error — it simply won’t run, which makes the problem easy to miss until you discover missing coverage.
An empty parameter list is never a valid end state for a committed test. Suppressing this issue is not appropriate, as the test will not run until values are provided.
Regressions can go undetected when tests are skipped silently without failing the build.
Add at least one case tuple to the @pytest.mark.parametrize values list so the test body actually runs.
If the test is not ready yet, do not simply remove the decorator while keeping its parameters: pytest will treat those names as fixtures and fail
at setup with fixture '…' not found. Instead, either add the missing cases, rewrite the test without parametrization (inline the values
in the function body), or mark the test explicitly with @pytest.mark.skip(reason="…") on a parameterless function.
import pytest
@pytest.mark.parametrize('operand,expected', [])
def test_double(operand, expected):
assert double(operand) == expected # Noncompliant
import pytest
@pytest.mark.parametrize('operand,expected', [
(1, 2),
(2, 4),
(3, 6),
(0, 0),
])
def test_double(operand, expected):
assert double(operand) == expected