python-pytest-cases icon indicating copy to clipboard operation
python-pytest-cases copied to clipboard

Add generators to case functions.

Open jenstroeger opened this issue 2 years ago • 2 comments
trafficstars

Following issue #229 and the discussion there, adding generators to case function requires discussion and some work:

  • What about pytest marks ? marking a single subcase (1 yield) / marking all subcases (all of the yields) ?
  • Should we consider the "return" of a generator ?
  • How to manage pytest ids one by one ? All at once ?
  • How to manage the compliance with the @case decorator ? (ids, filters, tags, etc.). Maybe the best way is to not create a new decorator but to have extra arguments in this decorator ?

Let the conversation begin 🤓

jenstroeger avatar Nov 13 '23 10:11 jenstroeger

Thanks @jenstroeger ! I am curious to see the thoughts of the community of users here

smarie avatar Nov 18 '23 20:11 smarie

I think the feature itself would be useful and offer a lot of flexibility to improve automated, larger test sets — for example I’d create a generator which randomly picks a large number of example cases from a Faker provider.[^1] How nice would that be 🤓

As for implementing that in your package and answering the above questions, I’m not fluent enough with the details of the pytest implementation… but hopefully the community can help out so this feature can come alive soon 🤞🏼

[^1]: In fact, this feature request is somewhat motivated by the discussion here: HypothesisWorks/hypothesis#3614.

jenstroeger avatar Nov 19 '23 08:11 jenstroeger