HypothesisWorks / hypothesis

Hypothesis is a powerful, flexible, and easy to use library for property-based testing.
https://hypothesis.works
Other
7.58k stars 587 forks source link

Teach `st.functions()` to create generators and async functions in addition to plain functions #4149

Open Zac-HD opened 2 weeks ago

Zac-HD commented 2 weeks ago

I think the natural way to do this is keying it off the like= argument, and wrap the standard implementation for each await/iteration... if that works with the inferred-return-type logic. We do need to branch on the result from inspect.is* at some point, to define functions with the same characteristics!

Maybe @proxies should also do this? We'd still need to handle the yielding of generators...

This would technically be a compatibility break, almost only of things that don't work at the moment, but we'll want to check that before shipping it in a non-major version.