Test case naming function (alternative to ids=) #6837
Labels
topic: parametrize
related to @pytest.mark.parametrize
type: proposal
proposal for a new feature, often to gather opinions or design the API around the new feature
After migration to pytest, I am frequently missing feature with regard to test parametrization that I used in the
parameterized
library:Ability to generate test ID based on the entire set of values.
In
parameterized
, this has been implemented as antestcase_func_name
argument, which is similar to theids
argument. With one notable exception:ids
operates on individual valuestestcase_func_name
operates on the entire set of valuesThe latter is much more flexible when it comes to dropping, reordering or combining values.
At the moment, I'm forced to use utility functions instead that take take a list of example values and map it to
pytest.param
:and use it as:
(artificial example for shortness, I'm sure you can imagine more creative ways of combining the values)
Or even simpler, allowing a string that is treated as an input for
str.format()
:and use it as:
You can see this is a short and elegant way of providing well readable names for test cases.
I searched the existing issues and the closest one on similar topic was #6335. I agree with not modifying the existing
ids
argument that is already quite complex. However, would it be an option to implement functionality similar to above using new argument(s)? (testcase_func_name
,testcase_format_name
, or anything else)The end results could look something like:
The text was updated successfully, but these errors were encountered: