# hypothesis

> The property-based testing library for Python

- **URL**: https://www.freshcrate.ai/projects/hypothesis
- **Author**: pypi
- **Category**: Frameworks
- **Latest version**: `v6.155.2` (2026-06-05)
- **License**: Unknown
- **Source**: https://github.com/HypothesisWorks/hypothesis/issues
- **Homepage**: https://pypi.org/project/hypothesis/
- **Language**: Python
- **GitHub**: 8,587 stars, 641 forks
- **Registry**: pypi (`hypothesis`)
- **Tags**: `fuzzing`, `property-based-testing`, `pypi`, `python`, `testing`

## 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).

## Recent releases

| Version | Date | Urgency | Changes |
| --- | --- | --- | --- |
| `v6.155.2` | 2026-06-05 | High | This patch rewrites the internal date- and time-drawing helper to use plain arithmetic instead of branching on the values it draws.  The generated distribution is unchanged, but "dates()", "datetimes()", and "times()" are now much more efficient under symbolic-execution backends such as crosshair-tool, which can now solve for a specific date directly rather than enumerating candidates (issue #4759).  *[The canonical version of these notes (with links) is on readthedocs.](https://hypothesis.readt |
| `v6.155.1` | 2026-05-29 | High | Shrinking large floats, strings, and bytestrings is now much faster in some cases (issue #4006).  *[The canonical version of these notes (with links) is on readthedocs.](https://hypothesis.readthedocs.io/en/latest/changelog.html#v6-155-1)* |
| `v6.153.0` | 2026-05-26 | High | "event()"'s "payload" is now typed as accepting "Any", matching its runtime behavior of accepting any string-coercible object.  *[The canonical version of these notes (with links) is on readthedocs.](https://hypothesis.readthedocs.io/en/latest/changelog.html#v6-153-0)* |
| `hypothesis-python-6.152.9` | 2026-05-19 | High | This release substantially improves our internal distribution for generating integers. This release has the most visible effect on "integers()", but may incidentally improve other strategies which draw integers internally.  Our integers distribution had two problems. First, it had jagged discontinuities at certain values where we switched sampling approaches. Second, it used a different distribution for bounded and unbounded ranges, which resulted in "st.integers()" and "st.integers(-2**64, 2**6 |
| `hypothesis-python-6.152.8` | 2026-05-18 | High | This release drops support for end-of-life Django 4.2.  *[The canonical version of these notes (with links) is on readthedocs.](https://hypothesis.readthedocs.io/en/latest/changelog.html#v6-152-8)* |
| `hypothesis-python-6.152.7` | 2026-05-13 | High | This patch improves our type hints for ".filter()" to work with "typing.TypeGuard". For example:     from typing import TypeGuard     from hypothesis import strategies as st     def is_str(x: object) -> TypeGuard[str]:        return isinstance(x, str)     s = st.from_type(object).filter(is_str)     # previously: SearchStrategy[object]    # now: SearchStrategy[str]    reveal_type(s)  *[The canonical version of these notes (with links) is on readthedocs.](https://hypothesis.readthedocs.io/en/lates |
| `hypothesis-python-6.152.5` | 2026-05-10 | High | This patch improves the "Phase.explain" phase so that simple cases like "assert n1 == n2" no longer get a misleading "# or any other generated value" comment (issue #4715). Before falling back to random sampling, we now also try borrowing values from each other arg slice with matching shape.  *[The canonical version of these notes (with links) is on readthedocs.](https://hypothesis.readthedocs.io/en/latest/changelog.html#v6-152-5)* |
| `hypothesis-python-6.152.4` | 2026-04-27 | High | This patch fixes a rare internal error during "Phase.explain" introduced in version 6.149.0 for certain strategies (issue #4708).  *[The canonical version of these notes (with links) is on readthedocs.](https://hypothesis.readthedocs.io/en/latest/changelog.html#v6-152-4)* |
| `hypothesis-python-6.152.2` | 2026-04-24 | High | This release further improves printing of generated values, building on the changes in  version 6.151.11.  Principle changes:  * In many cases where we would have printed a complex expression   producing a value, we now print the repr (or a pretty-printed   version of it).  * Additionally, in some cases where we would print a complex   expression that involved a lambda, we are now able to simplify that   expression into a more readable one.  *[The canonical version of these notes (with links) is |
| `6.152.1` | 2026-04-21 | Low | Imported from PyPI (6.152.1) |

## Citation

- HTML: https://www.freshcrate.ai/projects/hypothesis
- Markdown: https://www.freshcrate.ai/projects/hypothesis.md
- Dependencies JSON: https://www.freshcrate.ai/api/projects/hypothesis/deps

_Generated by freshcrate.ai. Indexes pypi releases for AI-agent ecosystem packages._
