From daa0c1b20122363234f56ad4266869b17994453f Mon Sep 17 00:00:00 2001 From: TanyaAgarwal28 <8979149361t@gmail.com> Date: Sun, 8 Oct 2023 17:38:49 +0530 Subject: [PATCH] Bug Fix 11456: Duplicated parameters in @pytest.mark.parametrize --- changelog/11456.bugfix.rst | 2 ++ testing/test_python.py | 13 +++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 changelog/11456.bugfix.rst create mode 100644 testing/test_python.py diff --git a/changelog/11456.bugfix.rst b/changelog/11456.bugfix.rst new file mode 100644 index 000000000..06ddea229 --- /dev/null +++ b/changelog/11456.bugfix.rst @@ -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. diff --git a/testing/test_python.py b/testing/test_python.py new file mode 100644 index 000000000..ca5532702 --- /dev/null +++ b/testing/test_python.py @@ -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