NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
PyPI, #384 most downloaded on PyPI
The property-based testing library for Python
Latest stable
6.170.17
Last release 2 days ago
20 Nov 2026
Ships on a steady schedule
a new release about every 9 days
Nearly every release is documented
notes for 60 of the last 60 stable releases
Nothing withdrawn
no release was ever pulled
14 years old
1596 releases · first in 2013
Drag across the ruler to compare, or tap a release to open it.
This reverts an undocumented change in 3.7.1 which broke installation on debian stable: The specifier for the hypothesis[django] extra\_requires had i
This reverts an undocumented change in 3.7.1 which broke installation on debian stable: The specifier for the hypothesis[django] extra_requires had introduced a wild card, which was not supported on the default version of pip.
This is a bug fix and internal improvements release.
This is a bug fix and internal improvements release.
In particular Hypothesis now tracks a tree of where it has already explored. This allows it to avoid some classes of duplicate examples, and significantly improves the performance of shrinking failing examples by allowing it to skip some shrinks that it can determine can't possibly work.
Hypothesis will no longer seed the global random arbitrarily unless you have asked it to using ~hypothesis.strategies.random_module
Shrinking would previously have not worked correctly in some special cases on Python 2, and would have resulted in suboptimal examples.
Your coding agent can read these notes before it upgrades. Set up the MCP server →
Rule based stateful testing now has an @invariant decorator that specifies methods that are run after init and after every step, allowing you to encod
This is a feature release.
New features:
Rule based stateful testing now has an @invariant decorator that specifies methods that are run after init and after every step, allowing you to encode properties that should be true at all times. Thanks to Tom Prince for this feature.
The ~hypothesis.strategies.decimals strategy now supports allow_nan and allow_infinity flags.
There are significantly more strategies available for numpy, including for generating arbitrary data types. Thanks to Zac Hatfield Dodds for this feature.
When using the ~hypothesis.strategies.data strategy you can now add a label as an argument to draw(), which will be printed along with the value when an example fails. Thanks to Peter Inglesby for this feature.
Bug fixes:
Bug fix: ~hypothesis.strategies.composite now preserves functions' docstrings.
The build is now reproducible and doesn't depend on the path you build it from. Thanks to Chris Lamb for this feature.
numpy strategies for the void data type did not work correctly. Thanks to Zac Hatfield Dodds for this fix.
There have also been a number of performance optimizations:
The ~hypothesis.strategies.permutations strategy is now significantly faster to use for large lists (the underlying algorithm has gone from O(n^2) to O(n)).
Shrinking of failing test cases should have got significantly faster in some circumstances where it was previously struggling for a long time.
Example generation now involves less indirection, which results in a small speedup in some cases (small enough that you won't really notice it except in pathological cases).
This release fixes a dependency problem and makes some small behind the scenes improvements.
This release fixes a dependency problem and makes some small behind the scenes improvements.
The fake-factory dependency was renamed to faker. If you were depending on it through hypothesis[django] or hypothesis[fake-factory] without pinning it yourself then it would have failed to install properly. This release changes it so that hypothesis[fakefactory] (which can now also be installed as hypothesis[faker]) will install the renamed faker package instead.
This release also removed the dependency of hypothesis[django] on hypothesis[fakefactory] - it was only being used for emails. These now use a custom strategy that isn't from fakefactory. As a result you should also see performance improvements of tests which generated User objects or other things with email fields, as well as better shrinking of email addresses.
The distribution of code using nested calls to ~hypothesis.strategies.one_of or the | operator for combining strategies has been improved, as branches are now flattened to give a more uniform distribution.
Examples using ~hypothesis.strategies.composite or |.flatmap| should now shrink better. In particular this will affect things which work by first generating a length and then generating that many items, which have historically not shrunk very well.
This release reverts Hypothesis to its old pretty printing of lambda functions based on attempting to extract the source code rather than decompile th
This release reverts Hypothesis to its old pretty printing of lambda functions based on attempting to extract the source code rather than decompile the bytecode. This is unfortunately slightly inferior in some cases and may result in you occasionally seeing things like lambda x: <unknown> in statistics reports and strategy reprs.
This removes the dependencies on uncompyle6, xdis and spark-parser.
The reason for this is that the new functionality was based on uncompyle6, which turns out to introduce a hidden GPLed dependency - it in turn depended on xdis, and although the library was licensed under the MIT license, it contained some GPL licensed source code and thus should have been released under the GPL.
My interpretation is that Hypothesis itself was never in violation of the GPL (because the license it is under, the Mozilla Public License v2, is fully compatible with being included in a GPL licensed work), but I have not consulted a lawyer on the subject. Regardless of the answer to this question, adding a GPLed dependency will likely cause a lot of users of Hypothesis to inadvertently be in violation of the GPL.
As a result, if you are running Hypothesis 3.5.x you really should upgrade to this release immediately.
If the same test was running concurrently in two processes and there were examples already in the test database which no longer failed, Hypothesis wou
This is a bug fix release.
Bugs fixed:
If the same test was running concurrently in two processes and there were examples already in the test database which no longer failed, Hypothesis would sometimes fail with a FileNotFoundError (IOError on Python 2) because an example it was trying to read was deleted before it was read. (372).
Drawing from an ~hypothesis.strategies.integers strategy with both a min_value and a max_value would reject too many examples needlessly. Now it repeatedly redraws until satisfied. (366. Thanks to Calen Pennington for the contribution).
The Hypothesis pytest plugin broke pytest support for doctests. Now it doesn't.
This is a bug fix release.
The Hypothesis pytest plugin broke pytest support for doctests. Now it doesn't.
Hypothesis now runs cleanly in -B and -BB modes, avoiding mixing bytes and unicode.
This is a bug fix release.
Hypothesis now runs cleanly in -B and -BB modes, avoiding mixing bytes and unicode.
python:unittest.TestCase tests would not have shown up in the new statistics mode. Now they do.
Similarly, stateful tests would not have shown up in statistics and now they do.
Statistics now print with pytest node IDs (the names you'd get in pytest verbose mode).
~hypothesis.strategies.fractions and ~hypothesis.strategies.decimals strategies now support min_value and max_value parameters. Thanks go to Anne Mulh
This is a feature release.
~hypothesis.strategies.fractions and ~hypothesis.strategies.decimals strategies now support min_value and max_value parameters. Thanks go to Anne Mulhern for the development of this feature.
The Hypothesis pytest plugin now supports a --hypothesis-show-statistics parameter that gives detailed statistics about the tests that were run. Huge thanks to Jean-Louis Fuchs and Adfinis-SyGroup for funding the development of this feature.
There is a new ~hypothesis.event function that can be used to add custom statistics.
Additionally there have been some minor bug fixes:
In some cases Hypothesis should produce fewer duplicate examples (this will mostly only affect cases with a single parameter).
pytest command line parameters are now under an option group for Hypothesis (thanks to David Keijser for fixing this)
Hypothesis would previously error if you used 3107 function annotations on your tests under Python 3.4.
The repr of many strategies using lambdas has been improved to include the lambda body (this was previously supported in many but not all cases).
This is a bug fix release, fixing a number of problems with the settings system:
This is a bug fix release, fixing a number of problems with the settings system:
Test functions defined using @given can now be called from other threads (337)
Attempting to delete a settings property would previously have silently done the wrong thing. Now it raises an AttributeError.
Creating a settings object with a custom database_file parameter was silently getting ignored and the default was being used instead. Now it's not.
This is a bug fix release for a single bug:
This is a bug fix release for a single bug:
On Windows when running two Hypothesis processes in parallel (e.g. using pytest-xdist) they could race with each other and one would raise an exception due to the non-atomic nature of file renaming on Windows and the fact that you can't rename over an existing file. This is now fixed.
This release is entirely provided by Lucas Wiman _:
This release is entirely provided by Lucas Wiman:
Strategies constructed by the Django extra will now respect much more of Django's validations out of the box. Wherever possible, ~django:django.db.models.Model.full_clean should succeed.
In particular:
The max_length, blank and choices kwargs are now respected.
Add support for DecimalField.
If a field includes validators, the list of validators are used to filter the field strategy.
This release went wrong and is functionally equivalent to 3.2.0 . Ignore it.
This release went wrong and is functionally equivalent to 3.2.0. Ignore it.
This is a small single-feature release:
This is a small single-feature release:
All tests using @given now fix the global random seed. This removes the health check for that. If a non-zero seed is required for the final falsifying example, it will be reported. Otherwise Hypothesis will assume randomization was not a significant factor for the test and be silent on the subject. If you use ~hypothesis.strategies.random_module this will continue to work and will always display the seed.
Another charmap problem. In 3.1.2 ~hypothesis.strategies.text and ~hypothesis.strategies.characters would break on systems which had /tmp mounted on a
Single bug fix release
Another charmap problem. In 3.1.2 ~hypothesis.strategies.text and ~hypothesis.strategies.characters would break on systems which had /tmp mounted on a different partition than the Hypothesis storage directory (usually in home). This fixes that.
Single bug fix release
Another charmap problem. In 3.1.2 text() and characters() would break on systems which had /tmp mounted on a different partition than the Hypothesis storage directory (usually in home). This fixes that.
Anything which used a ~hypothesis.strategies.text or ~hypothesis.strategies.characters strategy was broken on Windows and I hadn't updated appveyor to
Single bug fix release:
Anything which used a ~hypothesis.strategies.text or ~hypothesis.strategies.characters strategy was broken on Windows and I hadn't updated appveyor to use the new repository location so I didn't notice. This is now fixed and windows support should work correctly.
Fix concurrency issue when running tests that use ~hypothesis.strategies.text from multiple processes at once (302, thanks to Alex Chan).
Minor bug fix release.
Fix concurrency issue when running tests that use ~hypothesis.strategies.text from multiple processes at once (302, thanks to Alex Chan).
Improve performance of code using ~hypothesis.strategies.lists with max_size (thanks to Cristi Cobzarenco).
Fix install on Python 2 with ancient versions of pip so that it installs the enum34 backport (thanks to Donald Stufft for telling me how to do this).
Remove duplicated __all__ exports from hypothesis.strategies (thanks to Piët Delport).
Update headers to point to new repository location.
Allow use of strategies that can't be used in find() (e.g. choices()) in stateful testing.
Add a ~hypothesis.strategies.nothing strategy that never successfully generates values.
Add a ~hypothesis.strategies.nothing strategy that never successfully generates values.
~hypothesis.strategies.sampled_from and ~hypothesis.strategies.one_of can both now be called with an empty argument list, in which case they also never generate any values.
~hypothesis.strategies.one_of may now be called with a single argument that is a collection of strategies as well as varargs.
Add a ~hypothesis.strategies.runner strategy which returns the instance of the current test object if there is one.
'Bundle' for RuleBasedStateMachine is now a normal(ish) strategy and can be used as such.
Tests using RuleBasedStateMachine should now shrink significantly better.
Hypothesis now uses a pretty-printing library internally, compatible with IPython's pretty printing protocol (actually using the same code). This may improve the quality of output in some cases.
Add a 'phases' setting that allows more fine grained control over which parts of the process Hypothesis runs
Add a suppress_health_check setting which allows you to turn off specific health checks in a fine grained manner.
Fix a bug where lists of non fixed size would always draw one more element than they included. This mostly didn't matter, but if would cause problems with empty strategies or ones with side effects.
Add a mechanism to the Django model generator to allow you to explicitly request the default value (thanks to Jeremy Thurgood for this one).
Fix a bug where Hypothesis would now error on pytest development versions.
Fix a bug where Hypothesis would now error on pytest development versions.
Fix a bug where Hypothesis would error when running on Python 2.7.3 or earlier because it was trying to pass a python:bytearray object to python:struc
Fix a bug where Hypothesis would error when running on Python 2.7.3 or earlier because it was trying to pass a python:bytearray object to python:struct.unpack (which is only supported since 2.7.4).
Fix a bug where Hypothesis would error when running on Python 2.7.3 or earlier because it was trying to pass a bytearray object to struct.unpack() (which is only supported since 2.7.4).
Fix version parsing of pytest to work with pytest release candidates
Fix version parsing of pytest to work with pytest release candidates
More general handling of the health check problem where things could fail because of a cache miss - now one "free" example is generated before the start of the health check run.
Under certain circumstances, strategies involving ~hypothesis.strategies.text buried inside some other strategy (e.g. text().filter(...) or recursive(
Under certain circumstances, strategies involving ~hypothesis.strategies.text buried inside some other strategy (e.g. text().filter(...) or recursive(text(), ...)) would cause a test to fail its health checks the first time it ran. This was caused by having to compute some related data and cache it to disk. On travis or anywhere else where the .hypothesis directory was recreated this would have caused the tests to fail their health check on every run. This is now fixed for all the known cases, although there could be others lurking.
Fix a case where it was possible to trigger an "Unreachable" assertion when running certain flaky stateful tests.
Fix a case where it was possible to trigger an "Unreachable" assertion when running certain flaky stateful tests.
Improve shrinking of large stateful tests by eliminating a case where it was hard to delete early steps.
Improve efficiency of drawing binary(min_size=n, max_size=n) significantly by provide a custom implementation for fixed size blocks that can bypass a lot of machinery.
Set default home directory based on the current working directory at the point Hypothesis is imported, not whenever the function first happens to be called.
Externally this looks like a very small release. It has one small breaking change that probably doesn't affect anyone at all (some behaviour that neve…
Codename: This really should have been 2.1.
Externally this looks like a very small release. It has one small breaking change that probably doesn't affect anyone at all (some behaviour that never really worked correctly is now outright forbidden) but necessitated a major version bump and one visible new feature.
Internally this is a complete rewrite. Almost nothing other than the public API is the same.
New features:
Addition of ~hypothesis.strategies.data strategy which allows you to draw arbitrary data interactively within the test.
New "exploded" database format which allows you to more easily check the example database into a source repository while supporting merging.
Better management of how examples are saved in the database.
Health checks will now raise as errors when they fail. It was too easy to have the warnings be swallowed entirely.
New limitations:
choices() and streaming() strategies may no longer be used with find(). Neither may ~hypothesis.strategies.data (this is the change that necessitated a major version bump).
Feature removal:
The ForkingTestCase executor has gone away. It may return in some more working form at a later date.
Performance improvements:
A new model which allows flatmap, composite strategies and stateful testing to perform much better. They should also be more reliable.
Filtering may in some circumstances have improved significantly. This will help especially in cases where you have lots of values with individual filters on them, such as lists(x.filter(...)).
Modest performance improvements to the general test runner by avoiding expensive operations
In general your tests should have got faster. If they've instead got significantly slower, I'm interested in hearing about it.
Data distribution:
The data distribution should have changed significantly. This may uncover bugs the previous version missed. It may also miss bugs the previous version could have uncovered. Hypothesis is now producing less strongly correlated data than it used to, but the correlations are extended over more of the structure.
Shrinking:
Shrinking quality should have improved. In particular Hypothesis can now perform simultaneous shrinking of separate examples within a single test (previously it was only able to do this for elements of a single collection). In some cases performance will have improved, in some cases it will have got worse but generally shouldn't have by much.
These are mostly things that were emitting deprecation warnings in 1.19.0, but there were a few additional changes.
Codename: A new beginning
This release cleans up all of the legacy that accrued in the course of Hypothesis 1.0. These are mostly things that were emitting deprecation warnings in 1.19.0, but there were a few additional changes.
In particular:
non-strategy values will no longer be converted to strategies when used in given or find.
FailedHealthCheck is now an error and not a warning.
Handling of non-ascii reprs in user types have been simplified by using raw strings in more places in Python 2.
given no longer allows mixing positional and keyword arguments.
given no longer works with functions with defaults.
given no longer turns provided arguments into defaults - they will not appear in the argspec at all.
the basic() strategy no longer exists.
the n_ary_tree strategy no longer exists.
the average_list_length setting no longer exists. Note: If you're using using recursive() this will cause you a significant slow down. You should pass explicit average_size parameters to collections in recursive calls.
@rule can no longer be applied to the same method twice.
Python 2.6 and 3.3 are no longer officially supported, although in practice they still work fine.
This also includes two non-deprecation changes:
given's keyword arguments no longer have to be the rightmost arguments and can appear anywhere in the method signature.
The max_shrinks setting would sometimes not have been respected.
It's primary purpose is some final deprecations prior to said release. The goal is that if your code emits no warnings under this release then it will…
Codename: IT COMES
This release heralds the beginning of a new and terrible age of Hypothesis 2.0.
It's primary purpose is some final deprecations prior to said release. The goal is that if your code emits no warnings under this release then it will probably run unchanged under Hypothesis 2.0 (there are some caveats to this: 2.0 will drop support for some Python versions, and if you're using internal APIs then as usual that may break without warning).
It does have two new features:
New @seed() decorator which allows you to manually seed a test. This may be harmlessly combined with and overrides the derandomize setting.
settings objects may now be used as a decorator to fix those settings to a particular @given test.
API changes (old usage still works but is deprecated):
Settings has been renamed to settings (lower casing) in order to make the decorator usage more natural.
Functions for the storage directory that were in hypothesis.settings are now in a new hypothesis.configuration module.
Additional deprecations:
the average_list_length setting has been deprecated in favour of being explicit.
the basic() strategy has been deprecated as it is impossible to support it under a Conjecture based model, which will hopefully be implemented at some point in the 2.x series.
the n_ary_tree strategy (which was never actually part of the public API) has been deprecated.
Passing settings or random as keyword arguments to given is deprecated (use the new functionality instead)
Bug fixes:
No longer emit PendingDeprecationWarning for __iter__ and StopIteration in streaming() values.
When running in health check mode with non strict, don't print quite so many errors for an exception in reify.
When an assumption made in a test or a filter is flaky, tests will now raise Flaky instead of UnsatisfiedAssumption.
Hypothesis will no longer write generated code to the file system. This will improve performance on some systems (e.g. if you're using PythonAnywhere
Two behind the scenes changes:
Hypothesis will no longer write generated code to the file system. This will improve performance on some systems (e.g. if you're using PythonAnywhere which is running your code from NFS) and prevent some annoying interactions with auto-restarting systems.
Hypothesis will cache the creation of some strategies. This can significantly improve performance for code that uses flatmap or composite and thus has to instantiate strategies a lot.
Tests and find are now explicitly seeded off the global random module. This means that if you nest one inside the other you will now get a health chec
Features:
Tests and find are now explicitly seeded off the global random module. This means that if you nest one inside the other you will now get a health check error. It also means that you can control global randomization by seeding random.
There is a new random_module() strategy which seeds the global random module for you and handles things so that you don't get a health check warning if you use it inside your tests.
floats() now accepts two new arguments: allow_nan and allow_infinity. These default to the old behaviour, but when set to False will do what the names suggest.
Bug fixes:
Fix a bug where tests that used text() on Python 3.4+ would not actually be deterministic even when explicitly seeded or using the derandomize mode, because generation depended on dictionary iteration order which was affected by hash randomization.
Fix a bug where with complicated strategies the timing of the initial health check could affect the seeding of the subsequent test, which would also render supposedly deterministic tests non-deterministic in some scenarios.
In some circumstances flatmap() could get confused by two structurally similar things it could generate and would produce a flaky test where the first time it produced an error but the second time it produced the other value, which was not an error. The same bug was presumably also possible in composite().
flatmap() and composite() initial generation should now be moderately faster. This will be particularly noticeable when you have many values drawn from the same strategy in a single run, e.g. constructs like lists(s.flatmap(f)). Shrinking performance may have suffered, but this didn't actually produce an interestingly worse result in any of the standard scenarios tested.
A small bug fix release, which fixes the fact that the 'note' function could not be used on tests which used the @example decorator to provide explici
A small bug fix release, which fixes the fact that the 'note' function could not be used on tests which used the @example decorator to provide explicit examples.
This is actually the same release as 1.16.1, but 1.16.1 has been pulled because it contains the following additional change that was not intended to b
This is actually the same release as 1.16.1, but 1.16.1 has been pulled because it contains the following additional change that was not intended to be in a patch release (it's perfectly stable, but is a larger change that should have required a minor version bump):
Hypothesis will now perform a series of "health checks" as part of running your tests. These detect and warn about some common error conditions that people often run into which wouldn't necessarily have caused the test to fail but would cause e.g. degraded performance or confusing results.
There are no public API changes in this release but it includes a behaviour change that I wasn't comfortable putting in a patch release.
There are no public API changes in this release but it includes a behaviour change that I wasn't comfortable putting in a patch release.
Functions from hypothesis.strategies will no longer raise InvalidArgument on bad arguments. Instead the same errors will be raised when a test using such a strategy is run. This may improve startup time in some cases, but the main reason for it is so that errors in strategies won't cause errors in loading, and it can interact correctly with things like pytest.mark.skipif.
Errors caused by accidentally invoking the legacy API are now much less confusing, although still throw NotImplementedError.
hypothesis.extra.django is 1.9 compatible.
When tests are run with max_shrinks=0 this will now still rerun the test on failure and will no longer print "Trying example:" before each run. Additionally note() will now work correctly when used with max_shrinks=0.
A release with two new features.
A release with two new features.
A 'characters' strategy for more flexible generation of text with particular character ranges and types, kindly contributed by Alexander Shorin.
Add support for preconditions to the rule based stateful testing. Kindly contributed by Christopher Armstrong
Add 'note' function which lets you include additional information in the final test run's output.
New features:
Add 'note' function which lets you include additional information in the final test run's output.
Add 'choices' strategy which gives you a choice function that emulates random.choice.
Add 'uuid' strategy that generates UUIDs'
Add 'shared' strategy that lets you create a strategy that just generates a single shared value for each test run
Bugs:
Using strategies of the form streaming(x.flatmap(f)) with find or in stateful testing would have caused InvalidArgument errors when the resulting values were used (because code that expected to only be called within a test context would be invoked).
This is quite a small release, but deprecates some public API functions and removes some internal API functionality so gets a minor version bump.
This is quite a small release, but deprecates some public API functions and removes some internal API functionality so gets a minor version bump.
All calls to the 'strategy' function are now deprecated, even ones which pass just a SearchStrategy instance (which is still a no-op).
Never documented hypothesis.extra entry_points mechanism has now been removed ( it was previously how hypothesis.extra packages were loaded and has been deprecated and unused for some time)
Some corner cases that could previously have produced an OverflowError when simplifying failing cases using hypothesis.extra.datetimes (or dates or times) have now been fixed.
Hypothesis load time for first import has been significantly reduced - it used to be around 250ms (on my SSD laptop) and now is around 100-150ms. This almost never matters but was slightly annoying when using it in the console.
hypothesis.strategies.randoms was previously missing from __all__.
Deprecates mutability of Settings, both the Settings.default top level property and individual settings.
Significantly improved performance of creating strategies using the functions from the hypothesis.strategies module by deferring the calculation of their repr until it was needed. This is unlikely to have been an performance issue for you unless you were using flatmap, composite or stateful testing, but for some cases it could be quite a significant impact.
A number of cases where the repr of strategies build from lambdas is improved
Add dates() and times() strategies to hypothesis.extra.datetimes
Add new 'profiles' mechanism to the settings system
Deprecates mutability of Settings, both the Settings.default top level property and individual settings.
A Settings object may now be directly initialized from a parent Settings.
@given should now give a better error message if you attempt to use it with a function that uses destructuring arguments (it still won't work, but it will error more clearly),
A number of spelling corrections in error messages
pytest should no longer display the intermediate modules Hypothesis generates when running in verbose mode
Hypothesis should now correctly handle printing objects with non-ascii reprs on python 3 when running in a locale that cannot handle ascii printing to stdout.
Add a unique=True argument to lists(). This is equivalent to unique_by=lambda x: x, but offers a more convenient syntax.
Hide modifications Hypothesis needs to make to sys.path by undoing them after we've imported the relevant modules. This is a workaround for issues cry
Hide modifications Hypothesis needs to make to sys.path by undoing them after we've imported the relevant modules. This is a workaround for issues cryptography experienced on windows.
Slightly improved performance of drawing from sampled_from on large lists of alternatives.
Significantly improved performance of drawing from one_of or strategies using | (note this includes a lot of strategies internally - floats() and integers() both fall into this category). There turned out to be a massive performance regression introduced in 1.10.0 affecting these which probably would have made tests using Hypothesis significantly slower than they should have been.
Better argument validation for datetimes() strategy - previously setting max_year < datetime.MIN_YEAR or min_year > datetime.MAX_YEAR would not have r
Better argument validation for datetimes() strategy - previously setting max_year < datetime.MIN_YEAR or min_year > datetime.MAX_YEAR would not have raised an InvalidArgument error and instead would have behaved confusingly.
Compatibility with being run on pytest < 2.7 (achieved by disabling the plugin).
Remove use of deprecated API in pytest plugin so as to not emit warning
Bug fixes:
Settings(database=my_db) would not be correctly inherited when used as a default setting, so that newly created settings would use the database_file setting and create an SQLite example database.
Settings.default.database = my_db would previously have raised an error and now works.
Timeout could sometimes be significantly exceeded if during simplification there were a lot of examples tried that didn't trigger the bug.
When loading a heavily simplified example using a basic() strategy from the database this could cause Python to trigger a recursion error.
Remove use of deprecated API in pytest plugin so as to not emit warning
Misc:
hypothesis-pytest is now part of hypothesis core. This should have no externally visible consequences, but you should update your dependencies to remove hypothesis-pytest and depend on only Hypothesis.
Better repr for hypothesis.extra.datetimes() strategies.
Add .close() method to abstract base class for Backend (it was already present in the main implementation).
Running on 3.5, Hypothesis would have emitted deprecation warnings because of use of inspect.getargspec
Bug fixes:
When running Hypothesis tests in parallel (e.g. using pytest-xdist) there was a race condition caused by code generation.
Example databases are now cached per thread so as to not use sqlite connections from multiple threads. This should make Hypothesis now entirely thread safe.
floats() with only min_value or max_value set would have had a very bad distribution.
Running on 3.5, Hypothesis would have emitted deprecation warnings because of use of inspect.getargspec
text() with a non-string alphabet would have used the repr() of the alphabet instead of its contexts. This is obviously silly. It now works with any s
text() with a non-string alphabet would have used the repr() of the alphabet instead of its contexts. This is obviously silly. It now works with any sequence of things convertible to unicode strings.
@given will now work on methods whose definitions contains no explicit positional arguments, only varargs (118). This may have some knock on effects because it means that @given no longer changes the argspec of functions other than by adding defaults.
Introduction of new @composite feature for more natural definition of strategies you'd previously have used flatmap for.
Fix support for fixtures on Django 1.7.
Fix support for fixtures on Django 1.7.
Nothing published for this version
If the database_file setting is set to None, this would have resulted in an error when running tests. Now it does the same as setting database to None
Tiny bug fix release:
If the database_file setting is set to None, this would have resulted in an error when running tests. Now it does the same as setting database to None.
lists(elements, unique_by=some_function, min_size=n) would have raised a ValidationError if n > Settings.default.average_list_length because it would
Another small bug fix release.
lists(elements, unique_by=some_function, min_size=n) would have raised a ValidationError if n > Settings.default.average_list_length because it would have wanted to use an average list length shorter than the minimum size of the list, which is impossible. Now it instead defaults to twice the minimum size in these circumstances.
basic() strategy would have only ever produced at most ten distinct values per run of the test (which is bad if you e.g. have it inside a list). This was obviously silly. It will now produce a much better distribution of data, both duplicated and non duplicated.
This is a small bug fix release:
This is a small bug fix release:
star imports from hypothesis should now work correctly.
example quality for examples using flatmap will be better, as the way it had previously been implemented was causing problems where Hypothesis was erroneously labelling some examples as being duplicates.
Nothing published for this version
This is just a bugfix and performance release, but it changes some semi-public APIs, hence the minor version bump.
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.
The first is the deprecation of the hypothesis-extra mechanism. From now on all the packages that were previously bundled under it other than hypothes…
Codename: The great bundling.
This release contains two fairly major changes.
The first is the deprecation of the hypothesis-extra mechanism. From now on all the packages that were previously bundled under it other than hypothesis-pytest (which is a different beast and will remain separate). The functionality remains unchanged and you can still import them from exactly the same location, they just are no longer separate packages.
The second is that this introduces a new way of building strategies which lets you build up strategies recursively from other strategies.
It also contains the minor change that calling .example() on a strategy object will give you examples that are more representative of the actual data you'll get. There used to be some logic in there to make the examples artificially simple but this proved to be a bad idea.
This contains no functionality changes but fixes a mistake made with building the previous package that would have broken installation on Windows.
This contains no functionality changes but fixes a mistake made with building the previous package that would have broken installation on Windows.
When a call to floats() had endpoints which were not floats but merely convertible to one (e.g. integers), these would be included in the generated da
Bugs fixed:
When a call to floats() had endpoints which were not floats but merely convertible to one (e.g. integers), these would be included in the generated data which would cause it to generate non-floats.
Splitting lambdas used in the definition of flatmap, map or filter over multiple lines would break the repr, which would in turn break their usage.
"Falsifying example" would not have been printed when the failure came from an explicit example.
"Falsifying example" would not have been printed when the failure came from an explicit example.
When using ForkingTestCase you would usually not get the falsifying example printed if the process exited abnormally (e.g. due to os._exit).
Another small bugfix release:
When using ForkingTestCase you would usually not get the falsifying example printed if the process exited abnormally (e.g. due to os._exit).
Improvements to the distribution of characters when using text() with a default alphabet. In particular produces a better distribution of ascii and whitespace in the alphabet.
This is a small release that contains a workaround for people who have bad reprs returning non ascii text on Python 2.7. This is not a bug fix for Hyp
This is a small release that contains a workaround for people who have bad reprs returning non ascii text on Python 2.7. This is not a bug fix for Hypothesis per se because that's not a thing that is actually supposed to work, but Hypothesis leans more heavily on repr than is typical so it's worth having a workaround for.
Much more sensible reprs for strategies, especially ones that come from hypothesis.strategies. These should now have as reprs python code that would p
New features:
Much more sensible reprs for strategies, especially ones that come from hypothesis.strategies. These should now have as reprs python code that would produce the same strategy.
lists() accepts a unique_by argument which forces the generated lists to be only contain elements unique according to some function key (which must return a hashable value).
Better error messages from flaky tests to help you debug things.
Mostly invisible implementation details that may result in finding new bugs in your code:
Sets and dictionary generation should now produce a better range of results.
floats with bounds now focus more on 'critical values', trying to produce values at edge cases.
flatmap should now have better simplification for complicated cases, as well as generally being (I hope) more reliable.
Bug fixes:
You could not previously use assume() if you were using the forking executor.
This is purely a bug fix release:
This is purely a bug fix release:
When using floats() with stale data in the database you could sometimes get values in your tests that did not respect min_value or max_value.
When getting a Flaky error from an unreliable test it would have incorrectly displayed the example that caused it.
2.6 dependency on backports was incorrectly specified. This would only have caused you problems if you were building a universal wheel from Hypothesis, which is not how Hypothesis ships, so unless you're explicitly building wheels for your dependencies and support Python 2.6 plus a later version of Python this probably would never have affected you.
If you use flatmap in a way that the strategy on the right hand side depends sensitively on the left hand side you may have occasionally seen Flaky errors caused by producing unreliable examples when minimizing a bug. This use case may still be somewhat fraught to be honest. This code is due a major rearchitecture for 1.8, but in the meantime this release fixes the only source of this error that I'm aware of.
A slight technical hitch with a premature upload means there's was a yanked 1.7.0 release. Oops.
Codename: There is no 1.7.0.
A slight technical hitch with a premature upload means there's was a yanked 1.7.0 release. Oops.
The major feature of this release is Python 2.6 support. Thanks to Jeff Meadows for doing most of the work there.
Other minor features
strategies now has a permutations() function which returns a strategy yielding permutations of values from a given collection.
if you have a flaky test it will print the exception that it last saw before failing with Flaky, even if you do not have verbose reporting on.
Slightly experimental git merge script available as "python -m hypothesis.tools.mergedbs". Instructions on how to use it in the docstring of that file.
Bug fixes:
Better performance from use of filter. In particular tests which involve large numbers of heavily filtered strategies should perform a lot better.
floats() with a negative min_value would not have worked correctly (worryingly, it would have just silently failed to run any examples). This is now fixed.
tests using sampled_from would error if the number of sampled elements was smaller than min_satisfying_examples.
This is just a few small bug fixes:
This is just a few small bug fixes:
Size bounds were not validated for values for a binary() strategy when reading examples from the database.
sampled_from is now in __all__ in hypothesis.strategies
floats no longer consider negative integers to be simpler than positive non-integers
Small floating point intervals now correctly count members, so if you have a floating point interval so narrow there are only a handful of values in it, this will no longer cause an error when Hypothesis runs out of values.
This is a small patch release that fixes a bug where 1.6.0 broke the use of flatmap with the deprecated API and assumed the passed in function returne…
This is a small patch release that fixes a bug where 1.6.0 broke the use of flatmap with the deprecated API and assumed the passed in function returned a SearchStrategy instance rather than converting it to a strategy.
This is a smallish release designed to fix a number of bugs and smooth out some weird behaviours.
This is a smallish release designed to fix a number of bugs and smooth out some weird behaviours.
Fix a critical bug in flatmap where it would reuse old strategies. If all your flatmap code was pure you're fine. If it's not, I'm surprised it's working at all. In particular if you want to use flatmap with django models, you desperately need to upgrade to this version.
flatmap simplification performance should now be better in some cases where it previously had to redo work.
Fix for a bug where invalid unicode data with surrogates could be generated during simplification (it was already filtered out during actual generation).
The Hypothesis database is now keyed off the name of the test instead of the type of data. This makes much more sense now with the new strategies API and is generally more robust. This means you will lose old examples on upgrade.
The database will now not delete values which fail to deserialize correctly, just skip them. This is to handle cases where multiple incompatible strategies share the same key.
find now also saves and loads values from the database, keyed off a hash of the function you're finding from.
Stateful tests now serialize and load values from the database. They should have before, really. This was a bug.
Passing a different verbosity level into a test would not have worked entirely correctly, leaving off some messages. This is now fixed.
Fix a bug where derandomized tests with unicode characters in the function body would error on Python 2.7.
The old method of defining strategies will still work until Hypothesis 2.0, because it's a major breaking change, but will now emit deprecation warnin…
Codename: Strategic withdrawal.
The purpose of this release is a radical simplification of the API for building strategies. Instead of the old approach of @strategy.extend and things that get converted to strategies, you just build strategies directly.
The old method of defining strategies will still work until Hypothesis 2.0, because it's a major breaking change, but will now emit deprecation warnings.
The new API is also a lot more powerful as the functions for defining strategies give you a lot of dials to turn. See the updated data section for details.
Other changes:
Mixing keyword and positional arguments in a call to @given is deprecated as well.
There is a new setting called 'strict'. When set to True, Hypothesis will raise warnings instead of merely printing them. Turning it on by default is inadvisable because it means that Hypothesis minor releases can break your code, but it may be useful for making sure you catch all uses of deprecated APIs.
max_examples in settings is now interpreted as meaning the maximum number of unique (ish) examples satisfying assumptions. A new setting max_iterations which defaults to a larger value has the old interpretation.
Example generation should be significantly faster due to a new faster parameter selection algorithm. This will mostly show up for simple data types - for complex ones the parameter selection is almost certainly dominated.
Simplification has some new heuristics that will tend to cut down on cases where it could previously take a very long time.
timeout would previously not have been respected in cases where there were a lot of duplicate examples. You probably wouldn't have previously noticed this because max_examples counted duplicates, so this was very hard to hit in a way that mattered.
A number of internal simplifications to the SearchStrategy API.
You can now access the current Hypothesis version as hypothesis.__version__.
A top level function is provided for running the stateful tests without the TestCase infrastructure.
One column per quarter.