description
pytest==9.1.0 strict_parametrization_ids does not consider different data types as unique test cases
pytest is recommending provide unique pytest.param ids for two tests which are validating behavior str values vs int values.
Returning the error:
_________________________________________________________ ERROR collecting test_strict.py __________________________________________________________
Duplicate parametrization IDs detected, but strict_parametrization_ids is set.
Test name: test_strict.py::test_double_accepts_str_and_int
Parameters: val, expected
Parameter sets: [1, 2], ['1', 2]
IDs: 1-2, 1-2
Duplicates: 1-2
You can fix this problem using `@pytest.mark.parametrize(..., ids=...)` or `pytest.param(..., id=...)`.
pip list
$ pip list
Package Version
------------------------- ---------
attrs 26.1.0
certifi 2026.5.20
charset-normalizer 3.4.7
configobj 5.0.9
coverage 7.14.1
execnet 2.1.2
idna 3.18
iniconfig 2.3.0
Jinja2 3.1.6
jsonpatch 1.33
jsonpointer 3.1.1
jsonschema 4.26.0
jsonschema-specifications 2025.9.1
MarkupSafe 3.0.3
oauthlib 3.3.1
packaging 26.2
passlib 1.7.4
pip 25.1.1
pluggy 1.6.0
pyfakefs 6.2.0
Pygments 2.20.0
pyserial 3.5
pytest 9.1.0
pytest-cov 7.1.0
pytest-mock 3.15.1
pytest-xdist 3.8.0
PyYAML 6.0.3
referencing 0.37.0
requests 2.34.2
responses 0.26.1
rpds-py 2026.5.1
urllib3 2.7.0
reproducer:
cat > test_strict.py <<EOF
import pytest
def double(val):
try:
return 2 * int(val)
except ValueError:
return 2 * val
@pytest.mark.parametrize("val,expected", ((1, 2), ("1", 2)))
def test_double_accepts_str_and_int(val, expected):
assert expected == double(val)
EOF
pytest test_strict.py
....
description
pytest==9.1.0 strict_parametrization_ids does not consider different data types as unique test cases
pytest is recommending provide unique pytest.param ids for two tests which are validating behavior str values vs int values.
Returning the error:
pip list
reproducer: