hypothesis
The property-based testing library for Python
Description
<div align="center"> <img src="https://raw.githubusercontent.com/HypothesisWorks/hypothesis/master/brand/dragonfly-rainbow.svg" width="300"> </div> # Hypothesis * [Website](https://hypothesis.works/) * [Documentation](https://hypothesis.readthedocs.io/en/latest/) * [Source code](https://github.com/hypothesisWorks/hypothesis/) * [Contributing](https://github.com/HypothesisWorks/hypothesis/blob/master/CONTRIBUTING.rst) * [Community](https://hypothesis.readthedocs.io/en/latest/community.html) Hypothesis is the property-based testing library for Python. With Hypothesis, you write tests which should pass for all inputs in whatever range you describe, and let Hypothesis randomly choose which of those inputs to check - including edge cases you might not have thought about. For example: ```python from hypothesis import given, strategies as st @given(st.lists(st.integers())) def test_matches_builtin(ls): assert sorted(ls) == my_sort(ls) ``` This randomized testing can catch bugs and edge cases that you didn't think of and wouldn't have found. In addition, when Hypothesis does find a bug, it doesn't just report any failing example — it reports the simplest possible one. This makes property-based tests a powerful tool for debugging, as well as testing. For instance, ```python def my_sort(ls): return sorted(set(ls)) ``` fails with the simplest possible failing example: ``` Falsifying example: test_matches_builtin(ls=[0, 0]) ``` ### Installation To install Hypothesis: ``` pip install hypothesis ``` There are also [optional extras available](https://hypothesis.readthedocs.io/en/latest/extras.html).
Release History
| Version | Changes | Urgency | Date |
|---|---|---|---|
| 6.152.1 | Imported from PyPI (6.152.1) | Low | 4/21/2026 |
| hypothesis-python-6.152.1 | Improve some internal type hints. *[The canonical version of these notes (with links) is on readthedocs.](https://hypothesis.readthedocs.io/en/latest/changelog.html#v6-152-1)* | High | 4/14/2026 |
| hypothesis-python-6.152.0 | Hypothesis generally recommends that the ".hypothesis" directory not be checked into version control. As a result, Hypothesis now automatically creates a ".gitignore" with "*" in the ".hypothesis" directory, which excludes it from being tracked by git. If you do want to check ".hypothesis" into git, you can remove the ".gitignore" file. Hypothesis will not re-create it unless the entire ".hypothesis" directory is removed. *[The canonical version of these notes (with links) is on readthedocs.]( | Medium | 4/14/2026 |
| hypothesis-python-6.151.14 | This patch fixes our "from_regex()" type annotations so that "from_regex(..., alphabet=None)" is accepted. This patch also adds unicode line breaks and thai combining vowels to our list of constant strings to upweight at runtime. *[The canonical version of these notes (with links) is on readthedocs.](https://hypothesis.readthedocs.io/en/latest/changelog.html#v6-151-14)* | Medium | 4/13/2026 |
| hypothesis-python-6.151.13 | This patch removes some newly unnecessary "# type: ignore" comments. *[The canonical version of these notes (with links) is on readthedocs.](https://hypothesis.readthedocs.io/en/latest/changelog.html#v6-151-13)* | Medium | 4/13/2026 |
| hypothesis-python-6.151.12 | This release improves "Phase.explain" output by excluding pytest- related syrupy files as a possible source of variation. *[The canonical version of these notes (with links) is on readthedocs.](https://hypothesis.readthedocs.io/en/latest/changelog.html#v6-151-12)* | Medium | 4/8/2026 |
| hypothesis-python-6.151.11 | This patch improves printing of primitive values generated from complex strategies, particularly for "from_regex()". Previously, these would often be printed as function calls desctribing how to construct them. Now they will always be printed as a literal value. *[The canonical version of these notes (with links) is on readthedocs.](https://hypothesis.readthedocs.io/en/latest/changelog.html#v6-151-11)* | Medium | 4/5/2026 |
| hypothesis-python-6.151.10 | When shrinking takes more than five minutes, Hypothesis now prints the "@seed" decorator alongside the slow-shrinking warning so you can reproduce the failure. Thanks to Ian Hunt-Isaak for this contribution! *[The canonical version of these notes (with links) is on readthedocs.](https://hypothesis.readthedocs.io/en/latest/changelog.html#v6-151-10)* | Medium | 3/29/2026 |
| hypothesis-python-6.151.9 | Remove some old unused code. *[The canonical version of these notes (with links) is on readthedocs.](https://hypothesis.readthedocs.io/en/latest/changelog.html#v6-151-9)* | Low | 2/16/2026 |
| hypothesis-python-6.151.8 | This patch fixes a crash when "sys.modules" contains unhashable values, such as "SimpleNamespace" objects (issue #4660). *[The canonical version of these notes (with links) is on readthedocs.](https://hypothesis.readthedocs.io/en/latest/changelog.html#v6-151-8)* | Low | 2/16/2026 |
| hypothesis-python-6.151.7 | This patch updates our vendored list of top-level domains, which is used by the provisional "domains()" strategy. *[The canonical version of these notes (with links) is on readthedocs.](https://hypothesis.readthedocs.io/en/latest/changelog.html#v6-151-7)* | Low | 2/16/2026 |
| hypothesis-python-6.151.6 | This patch fixes several duplicate word typos in comments and documentation. *[The canonical version of these notes (with links) is on readthedocs.](https://hypothesis.readthedocs.io/en/latest/changelog.html#v6-151-6)* | Low | 2/11/2026 |
| hypothesis-python-6.151.5 | This patch teaches our pytest plugin to :ref:` find interesting constants <v6.131.1>` when pytest is collecting tests, to avoid arbitrarily attributing the latency to whichever test function happened to be executed first (issue #4627). *[The canonical version of these notes (with links) is on readthedocs.](https://hypothesis.readthedocs.io/en/latest/changelog.html#v6-151-5)* | Low | 2/3/2026 |
| hypothesis-python-6.151.4 | This patch adjusts how we compute the stopping threshold introduced in version 6.151.3, while still maintaining 99% confidence that <1% of test cases pass. *[The canonical version of these notes (with links) is on readthedocs.](https://hypothesis.readthedocs.io/en/latest/changelog.html#v6-151-4)* | Low | 1/29/2026 |
| hypothesis-python-6.151.3 | This patch makes Hypothesis more tolerant of slow-to-satisfy "assume()" calls. Previously, Hypothesis would give up after "max_examples * 10" attempts; now it uses a statistical test to stop only when 99% confident that <1% of examples would pass (issue #4623). Thanks to @ajdavis for this improvement! *[The canonical version of these notes (with links) is on readthedocs.](https://hypothesis.readthedocs.io/en/latest/changelog.html#v6-151-3)* | Low | 1/28/2026 |
| hypothesis-python-6.151.2 | Format our code with the latest version of black. *[The canonical version of these notes (with links) is on readthedocs.](https://hypothesis.readthedocs.io/en/latest/changelog.html#v6-151-2)* | Low | 1/26/2026 |
| hypothesis-python-6.151.1 | Improve internal categorization of test cases when an alternative backend raises "BackendCannotProceed". *[The canonical version of these notes (with links) is on readthedocs.](https://hypothesis.readthedocs.io/en/latest/changelog.html#v6-151-1)* | Low | 1/26/2026 |
| hypothesis-python-6.151.0 | Add 2025.12 to the list of recognized Array API versions in "hypothesis.extra.array_api". *[The canonical version of these notes (with links) is on readthedocs.](https://hypothesis.readthedocs.io/en/latest/changelog.html#v6-151-0)* | Low | 1/25/2026 |
| hypothesis-python-6.150.3 | Hypothesis now generates powers of 2 more often when using "integers()". *[The canonical version of these notes (with links) is on readthedocs.](https://hypothesis.readthedocs.io/en/latest/changelog.html#v6-150-3)* | Low | 1/23/2026 |
| hypothesis-python-6.150.2 | Update some internal type hints. *[The canonical version of these notes (with links) is on readthedocs.](https://hypothesis.readthedocs.io/en/latest/changelog.html#v6-150-2)* | Low | 1/13/2026 |
| hypothesis-python-6.150.1 | This patch fixes a bug where "recursive()" would fail in cases where the "extend=" function does not reference it's argument - which was assumed by the recent "min_leaves=" feature, because the strategy can't actually recurse otherwise. (issue #4638) Now, the historical behavior is working-but-deprecated, or an error if you explicitly pass "min_leaves=". *[The canonical version of these notes (with links) is on readthedocs.](https://hypothesis.readthedocs.io/en/latest/changelog.html#v6-150-1) | Low | 1/12/2026 |
| hypothesis-python-6.150.0 | This release adds a "min_leaves" argument to "recursive()", which ensures that generated recursive structures have at least the specified number of leaf nodes (issue #4205). *[The canonical version of these notes (with links) is on readthedocs.](https://hypothesis.readthedocs.io/en/latest/changelog.html#v6-150-0)* | Low | 1/6/2026 |
| hypothesis-python-6.149.1 | Add type hints to an internal class. *[The canonical version of these notes (with links) is on readthedocs.](https://hypothesis.readthedocs.io/en/latest/changelog.html#v6-149-1)* | Low | 1/5/2026 |
| hypothesis-python-6.149.0 | This release extends the explain-phase "# or any other generated value" comments to sub-arguments within "builds()", "tuples()", and "fixed_dictionaries()". Previously, these comments only appeared on top-level test arguments. Now, when the explain phase determines that a sub-argument can vary freely without affecting the test failure, you'll see comments like: Falsifying example: test_foo( obj=MyClass( x=0, # or any other generated value y=True, ), | Low | 1/5/2026 |
| hypothesis-python-6.148.13 | Clean up an internal helper. *[The canonical version of these notes (with links) is on readthedocs.](https://hypothesis.readthedocs.io/en/latest/changelog.html#v6-148-13)* | Low | 1/5/2026 |
| hypothesis-python-6.148.12 | This patch fixes "from_type()" to properly handle parameterized type aliases created with Python 3.12+'s **PEP 695** "type" statement. For example, "st.from_type(A[int])" where "type A[T] = list[T]" now correctly resolves to "lists(integers())" instead of raising a "TypeError" (issue #4628). *[The canonical version of these notes (with links) is on readthedocs.](https://hypothesis.readthedocs.io/en/latest/changelog.html#v6-148-12)* | Low | 1/4/2026 |
| hypothesis-python-6.148.11 | Hypothesis now prints a "Verbosity.verbose" log when we switch away from an alternative backend. *[The canonical version of these notes (with links) is on readthedocs.](https://hypothesis.readthedocs.io/en/latest/changelog.html#v6-148-11)* | Low | 1/3/2026 |
| hypothesis-python-6.148.10 | Fixes Ghostwriter output for numpy >= 2.4.0. Also adds support "from_type()" for numpy 2.5.0 nightly (which has not yet been released). *[The canonical version of these notes (with links) is on readthedocs.](https://hypothesis.readthedocs.io/en/latest/changelog.html#v6-148-10)* | Low | 1/3/2026 |
| hypothesis-python-6.148.9 | ".example()" no longer emits "NonInteractiveExampleWarning" when running a python file directly. This means that e.g. "python my_sandbox.py" during exploratory work with ".example()" will no longer raise warnings. *[The canonical version of these notes (with links) is on readthedocs.](https://hypothesis.readthedocs.io/en/latest/changelog.html#v6-148-9)* | Low | 1/1/2026 |
| hypothesis-python-6.148.8 | Add "__dict__" and "__proto__" to the list of constant strings Hypothesis sometimes generates. *[The canonical version of these notes (with links) is on readthedocs.](https://hypothesis.readthedocs.io/en/latest/changelog.html#v6-148-8)* | Low | 12/23/2025 |
| hypothesis-python-6.148.7 | When multiple explicit "@example" decorators fail with the same error, Hypothesis now shows only the simplest failing example (by shortlex order) with a note about how many other examples also failed (issue #4520). To see all failing examples, use "Verbosity.verbose" or higher. *[The canonical version of these notes (with links) is on readthedocs.](https://hypothesis.readthedocs.io/en/latest/changelog.html#v6-148-7)* | Low | 12/5/2025 |
| hypothesis-python-6.148.6 | Fix a bug where we persisted symbolics from solver-based alternative backends in "event()". *[The canonical version of these notes (with links) is on readthedocs.](https://hypothesis.readthedocs.io/en/latest/changelog.html#v6-148-6)* | Low | 12/4/2025 |
| hypothesis-python-6.148.5 | This patch improves the error message for "FlakyStrategyDefinition" when the precondition for a rule is flaky (issue #4206). *[The canonical version of these notes (with links) is on readthedocs.](https://hypothesis.readthedocs.io/en/latest/changelog.html#v6-148-5)* | Low | 12/1/2025 |
| hypothesis-python-6.148.4 | This patch improves the type annotations for "basic_indices()". The return type now accurately reflects the "allow_ellipsis" and "allow_newaxis" parameters, excluding "EllipsisType" or "None" from the union when those index types are disabled (issue #4607). Additionally, "assume()" now has overloaded type annotations: "assume(True)" returns "Literal[True]", while "assume(False)" and "assume(None)" return "NoReturn". *[The canonical version of these notes (with links) is on readthedocs.](https: | Low | 12/1/2025 |
| hypothesis-python-6.148.3 | Clean up some internal code. *[The canonical version of these notes (with links) is on readthedocs.](https://hypothesis.readthedocs.io/en/latest/changelog.html#v6-148-3)* | Low | 11/27/2025 |
| hypothesis-python-6.148.2 | Document "fuzz_one_input()". *[The canonical version of these notes (with links) is on readthedocs.](https://hypothesis.readthedocs.io/en/latest/changelog.html#v6-148-2)* | Low | 11/18/2025 |
| hypothesis-python-6.148.1 | This patch updates our vendored list of top-level domains, which is used by the provisional "domains()" strategy. *[The canonical version of these notes (with links) is on readthedocs.](https://hypothesis.readthedocs.io/en/latest/changelog.html#v6-148-1)* | Low | 11/16/2025 |
| hypothesis-python-6.148.0 | Calling "register_profile()" from within a test decorated with "@settings" is now deprecated, to avoid confusion about which settings are used as the baseline for the new profile. *[The canonical version of these notes (with links) is on readthedocs.](https://hypothesis.readthedocs.io/en/latest/changelog.html#v6-148-0)* | Low | 11/15/2025 |
| hypothesis-python-6.147.0 | This release drops support for nose, which ceased development 9 years ago and does not support Python 3.10 or newer. Hypothesis still supports nose2. While we do not test "nose2" in our CI, we will fix any bugs that get reported. *[The canonical version of these notes (with links) is on readthedocs.](https://hypothesis.readthedocs.io/en/latest/changelog.html#v6-147-0)* | Low | 11/6/2025 |
| hypothesis-python-6.146.0 | "@settings" now accepts equivalent string representations for "settings.verbosity", "settings.phases", and "settings.suppress_health_check". For example: # these two are now equivalent... settings(verbosity=Verbosity.verbose) settings(verbosity="verbose") # ...as are these two... settings(phases=[Phase.explicit]) settings(phases=["explicit"]) # ...and these two. settings(suppress_health_check=[HealthCheck.filter_too_much]) settings(suppress_health_check=["filter_too | Low | 11/5/2025 |
| hypothesis-python-6.145.1 | Refactor some internal logic around strategy definitions. *[The canonical version of these notes (with links) is on readthedocs.](https://hypothesis.readthedocs.io/en/latest/changelog.html#v6-145-1)* | Low | 11/3/2025 |
| hypothesis-python-6.145.0 | Hypothesis previously required attrs as a dependency. This release removes that dependency, so that the only required dependency of Hypothesis is sortedcontainers. All attrs-specific features of Hypothesis, such as using "from_type()" with attrs classes, will continue to behave as before. *[The canonical version of these notes (with links) is on readthedocs.](https://hypothesis.readthedocs.io/en/latest/changelog.html#v6-145-0)* | Low | 11/3/2025 |
| hypothesis-python-6.144.1 | Tweak how Hypothesis hides internal tracebacks to fix an error under rare conditions (issue #3822). *[The canonical version of these notes (with links) is on readthedocs.](https://hypothesis.readthedocs.io/en/latest/changelog.html#v6-144-1)* | Low | 11/3/2025 |
| hypothesis-python-6.144.0 | This release adds support for "Fraction" objects as "min_value" and "max_value" bounds in "decimals()", if they can be exactly represented as decimals in the target precision (issue #4466). Bounding "decimals()" with *other* values that cannot be exactly represented is now deprecated; previously the bounds could be off by one. *[The canonical version of these notes (with links) is on readthedocs.](https://hypothesis.readthedocs.io/en/latest/changelog.html#v6-144-0)* | Low | 11/2/2025 |
| hypothesis-python-6.143.1 | "from_type()" now correctly handles annotated-types annotations on "typing.TypedDict" fields which are also marked as being "ReadOnly", "Required", or "NotRequired" (issue #4474). *[The canonical version of these notes (with links) is on readthedocs.](https://hypothesis.readthedocs.io/en/latest/changelog.html#v6-143-1)* | Low | 11/2/2025 |
| hypothesis-python-6.143.0 | The extras for NumPy and pandas now support automatically inferring a strategy for "dtype="O"". Previously, Hypothesis required an explicit elements strategy to be passed, for example "nps.arrays("O", shape=(1,), elements=st.just(object()))". Now, Hypothesis automatically infers "elements=st.from_type(object)". Thanks to Shaun Read for identifying and fixing this! *[The canonical version of these notes (with links) is on readthedocs.](https://hypothesis.readthedocs.io/en/latest/changelog.html# | Low | 11/1/2025 |
| hypothesis-python-6.142.5 | This patch fixes "binary_operation()" to include imports for "hypothesis.extra.numpy" strategies such as "arrays()", "scalar_dtypes()", and "array_shapes()" when ghostwriting tests for functions with numpy array parameters (issue #4576). *[The canonical version of these notes (with links) is on readthedocs.](https://hypothesis.readthedocs.io/en/latest/changelog.html#v6-142-5)* | Low | 10/31/2025 |
| hypothesis-python-6.142.4 | Improve the accuracy of test timing reports, by tracking the start time of each test case closer to when the test is executed. *[The canonical version of these notes (with links) is on readthedocs.](https://hypothesis.readthedocs.io/en/latest/changelog.html#v6-142-4)* | Low | 10/25/2025 |
| hypothesis-python-6.142.3 | Fix a recursion error when observability is enabled and a test generates an object with a recursive reference, like "a = []; a.append(a)". *[The canonical version of these notes (with links) is on readthedocs.](https://hypothesis.readthedocs.io/en/latest/changelog.html#v6-142-3)* | Low | 10/22/2025 |
| hypothesis-python-6.142.2 | Remove a case where Hypothesis would interact with the global "random.Random" instance if Hypothesis internals were used directly. *[The canonical version of these notes (with links) is on readthedocs.](https://hypothesis.readthedocs.io/en/latest/changelog.html#v6-142-2)* | Low | 10/20/2025 |
| hypothesis-python-6.142.1 | Simplify some internal typing logic after dropping Python 3.9. *[The canonical version of these notes (with links) is on readthedocs.](https://hypothesis.readthedocs.io/en/latest/changelog.html#v6-142-1)* | Low | 10/16/2025 |
