pytest.mark.parametrize lists the same case twice
What it finds
A case listed twice in parametrize runs the same test twice and usually stands where a different case was meant, after a copy and an edit that was forgotten. Compared are the items of a literal list or tuple of cases, token by token.
From the rule's source, duplicate_parametrize_case.rs.
import pytest @pytest.mark.parametrize("a, b", [ (1, 2), (2, 3), (1, 2),tx0 reports: this case is listed before in the same parametrize])def test_add(a, b): pass @pytest.mark.parametrize("x", [1, 2, 3])def test_x(x): pass Turn it on, off or suppress it
The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/python:duplicate-parametrize-case" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
# tx0: ignore[tx0/python:duplicate-parametrize-case] reason="..."tx0 explain tx0/python:duplicate-parametrize-case shows the same in the terminal. Found a false positive? Report it.