Stop silently dropping examples when the @example() decorator is applied to itself
#3319
Labels
legibility
make errors helpful and Hypothesis grokable
Suppose you wanted to write a function which added explicit
@hypothesis.example()s to a function for the cross-product of a few sequences. A correct implementation would look something like:But if you forget the inner function, you'd end up with something like this:
To fix this, we should modify the definition of
@example()(below), so that thehypothesis_explicit_exampleslist is defined outside ofaccept, and added as an attribute on bothtestandaccept.hypothesis/hypothesis-python/src/hypothesis/core.py
Lines 136 to 151 in 7f1fa0b
For a complete pull request ("PR"), you'll also need to add a test which checks that examples are not lost when you chain together e.g.
example("outer")(example("inner"))(f), as well as writing aRELEASE.rstand adding your name to theAUTHORS.rstlist.The text was updated successfully, but these errors were encountered: