The general consensus when I asked about this, which was conveniently what I was already planning to do, was to save Hypothesis 2.0 for a big release where I wanted to make some significant changes and was happy to cut the deprecated APIs and such at that point. So for now we’re continuing on with the 1.x series.
This release actually doesn’t have any new features externally. I’ve introduced a new ‘cleanup’ function, which lets you register cleanup handlers that execute at the end of your tests (this is more useful inside strategies than it is inside tests, but you can use it in either), but its semantics as it interacts with find are a bit weird and so I’m not currently declaring it part of the public API.
Other than that, this is mostly a bug fix and performance release. It was supposed to be a small release which just contained the performance improvements to one_of that I blogged about previously, but it got held up by a pypy bug (I believe this is the first time that’s happened – previous bugs have been easy to diagnose and work around) and then snowballed into a bit more significant of a release.
Also, reminder that I have a Patreon now, and that if you like this release schedule some support for it would be appreciated.
This is just a bugfix and performance release, but it changes some semi-public APIs, hence the minor version bump.
- Significant performance improvements for strategies which are one_of() many branches. In particular this included recursive() strategies. This should take the case where you use one recursive() strategy as the base strategy of another from unusably slow (tens of seconds per generated example) to reasonably fast.
- Better handling of just() and sampled_from() for values which have an incorrect __repr__ implementation that returns non-ASCII unicode on Python 2.
- Better performance for flatmap from changing the internal morpher API to be significantly less general purpose.
- Introduce a new semi-public BuildContext/cleanup API. This allows strategies to register cleanup activities that should run once the example is complete. Note that this will interact somewhat weirdly with find.
- Better simplification behaviour for streaming strategies.
- Don’t error on lambdas which use destructuring arguments in Python 2.
- Add some better reprs for a few strategies that were missing good ones.
- The Random instances provided by randoms() are now copyable.
- Slightly more debugging information about simplify when using a debug verbosity level.
- Support using given for functions with varargs, but not passing arguments to it as positional.