Fix crash using empty string for parametrized value more than once
Fixes #11563.
This commit is contained in:
parent
ed8701a57f
commit
7156a97f9a
|
@ -0,0 +1 @@
|
||||||
|
Fixed crash when using an empty string for the same parametrized value more than once.
|
|
@ -1003,7 +1003,7 @@ class IdMaker:
|
||||||
for index, id in enumerate(resolved_ids):
|
for index, id in enumerate(resolved_ids):
|
||||||
if id_counts[id] > 1:
|
if id_counts[id] > 1:
|
||||||
suffix = ""
|
suffix = ""
|
||||||
if id[-1].isdigit():
|
if id and id[-1].isdigit():
|
||||||
suffix = "_"
|
suffix = "_"
|
||||||
new_id = f"{id}{suffix}{id_suffixes[id]}"
|
new_id = f"{id}{suffix}{id_suffixes[id]}"
|
||||||
while new_id in set(resolved_ids):
|
while new_id in set(resolved_ids):
|
||||||
|
|
|
@ -626,6 +626,13 @@ class TestMetafunc:
|
||||||
).make_unique_parameterset_ids()
|
).make_unique_parameterset_ids()
|
||||||
assert result == [expected]
|
assert result == [expected]
|
||||||
|
|
||||||
|
def test_idmaker_duplicated_empty_str(self) -> None:
|
||||||
|
"""Regression test for empty strings parametrized more than once (#11563)."""
|
||||||
|
result = IdMaker(
|
||||||
|
("a",), [pytest.param(""), pytest.param("")], None, None, None, None, None
|
||||||
|
).make_unique_parameterset_ids()
|
||||||
|
assert result == ["0", "1"]
|
||||||
|
|
||||||
def test_parametrize_ids_exception(self, pytester: Pytester) -> None:
|
def test_parametrize_ids_exception(self, pytester: Pytester) -> None:
|
||||||
"""
|
"""
|
||||||
:param pytester: the instance of Pytester class, a temporary
|
:param pytester: the instance of Pytester class, a temporary
|
||||||
|
|
Loading…
Reference in New Issue