-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Closed
Labels
topic: parametrizerelated to @pytest.mark.parametrizerelated to @pytest.mark.parametrizetype: bugproblem that needs to be addressedproblem that needs to be addressed
Description
What's the problem this feature will solve?
Make unambigious what the values of the parameters used from parametrize are.
Describe the solution you'd like
When duplicated values are used in parametrize, pytest adds a number after each duplicated value, starting from 0 and this confuses what the actual value of parameter is.
Example:
@pytest.mark.parametrize("a", [1, 2, 10, 11, 2, 1, 12, 11]
def test_params(a):
print('a:', a)
assert a > 0
This result in following output from pytest:
test_a_1.py::test_params[10] PASSED [ 12%]
test_a_1.py::test_params[20] PASSED [ 25%]
test_a_1.py::test_params[10] PASSED [ 25%]
test_a_1.py::test_params[110] PASSED [ 37%]
test_a_1.py::test_params[21] PASSED [ 50%]
test_a_1.py::test_params[11] PASSED [ 62%]
test_a_1.py::test_params[12] PASSED [ 75%]
test_a_1.py::test_params[111] PASSED [ 87%]
It is clear that a has the value 1
the very first time and not 10
, so confusing with the real 10
later.
Pytest adds a sequential nbr immediately after each duplicated value and that is very confusing
Alternative Solutions
Do not do this and leave the values as they are, so I would like following output:
1, 2, 10, 11, 2, 1, 12, 11 as in parametrize list
Metadata
Metadata
Assignees
Labels
topic: parametrizerelated to @pytest.mark.parametrizerelated to @pytest.mark.parametrizetype: bugproblem that needs to be addressedproblem that needs to be addressed