Bug Fix 11456: Duplicated parameters in @pytest.mark.parametrize

This commit is contained in:
TanyaAgarwal28 2023-10-08 17:38:49 +05:30
parent 92add35dca
commit daa0c1b201
2 changed files with 15 additions and 0 deletions

View File

@ -0,0 +1,2 @@
In this, we propose a solution that ensures the generation of unique identifiers for ParameterSets in the make_unique_parameterset_ids method in Python.py class. It appends numeric suffixes to identifiers, ensuring uniqueness even when the original identifiers have digit endings.
If the id ends in a digit, make then new id f"{id}_{suffix}". If the new id is already in the set of seen ids, increment the suffix number and try again. This is sure to work, and even be fast in practice, because our maximum suffix is the number of duplicate ids we started with.

13
testing/test_python.py Normal file
View File

@ -0,0 +1,13 @@
import pytest
@pytest.mark.parametrize("a", [1, 2, 10, 11, 2, 1, 12, 11, 2_1])
def test_params(a):
print("a:", a)
assert a > 0
@pytest.mark.parametrize("a", [1, 2, 10, 11, 2, 1, 12, 11])
def test_params_1(a):
print("a:", a)
assert a > 0