wolever / parameterized

Parameterized testing with any Python test framework
Other
833 stars 105 forks source link

Add id attribute to param #136

Closed souliane closed 1 year ago

souliane commented 2 years ago

It would be great to add an id attribute to param. This is useful in pytest to give custom names to tests, so that if one test fails, we can easily spot it.

c.f. test_timedistance_v3 in https://docs.pytest.org/en/6.2.x/example/parametrize.html?highlight=param#different-options-for-test-ids

wd60622 commented 2 years ago

You might be able to work around this with the doc_func param in parameterized

wolever commented 1 year ago

Hey! Would you be able to provide an example of a situation where a failed test does not include the parameters it was called with? I believe they should generally be displayed, but it's entirely possible one has been missed.

I'm going to close this issue for now, but please feel free to re-open if you're still interested!

souliane commented 1 year ago

Hi,

I think doc_func can achieve the same as param.id in pytest, but it's not as straightforward to use because you need to define a function, and build the string according to its params.

And yes, the params are displayed when the test fails, but sometimes it's handier to identity the test with a human readable description instead of the params values. My suggestion was about adding a possibility to set that human readable string at the param(...) level.

Anyway, I am fine with the current feature/behavior, thanks!