Hypothesis
hypothesis.works
What it is
Hypothesis is a free property-based testing library for Python. You describe behavior that your code should satisfy, and it generates inputs—including edge cases—to explore whether those properties hold. Strategies let you define and combine the data used in tests. When a failure appears, Hypothesis reports an example and tries to simplify it; failing examples are stored in a local test database for replay in later runs. Tests run as ordinary Python functions within pytest, unittest, nose, or another framework that can run a Python function. Hypothesis is not itself a test runner. By default, it generates 100 random inputs per test, and max_examples controls that count. Rule-based state machines can generate sequences of operations for testing stateful systems and objects. The project supports and tests CPython and PyPy 3.10 and later, and says it regularly works on Linux, macOS, Windows, and Emscripten. Its compatibility policy supports only the newest Hypothesis version; undocumented behavior may change in patch releases.
Spec sheet
- What it does
- Hypothesis is a property-based testing library for Python that generates inputs within ranges described by the user.Read 29 Sep 2026 · hypothesis.works
- Intended users
- Hypothesis is for people writing software tests who want to describe acceptable behavior and have the computer explore inputs.Read 28 Sep 2026 · hypothesis.works
- Integrations
- First-party extras include integrations for specific packages, and the documentation gives Django as an example installable extra.Read 29 Sep 2026 · hypothesis.readthedocs.io
- Community help
- Users can ask questions using the python-hypothesis Stack Overflow tag or join the mailing list for help and discussion.Read 29 Sep 2026 · hypothesis.readthedocs.io
- Compatibility limit
- The project supports only the most recent Hypothesis version; documented APIs are not expected to break except between major version bumps, while undocumented behavior may break in patch releases.Read 29 Sep 2026 · hypothesis.readthedocs.io
- Data generation
- Its strategies let users describe and compose the kinds of data their tests should generate.Read 28 Sep 2026 · hypothesis.works
- Default run count
- By default, Hypothesis generates 100 random inputs per test, and this count can be controlled with the max_examples setting.Read 29 Sep 2026 · hypothesis.readthedocs.io
- Development model
- The maintainers say new features must be sponsored or implemented by someone else, and the project has no long-term release plan.Read 29 Sep 2026 · hypothesis.readthedocs.io
- Edge cases
- Hypothesis randomly chooses inputs, including edge cases the user may not have considered.Read 29 Sep 2026 · hypothesis.works
- Operating systems
- The project says it is known to work and regularly tested on macOS, Windows, Linux, and Emscripten.Read 29 Sep 2026 · hypothesis.readthedocs.io
- Python support
- Hypothesis is supported and tested on CPython and PyPy 3.10 and later.Read 29 Sep 2026 · hypothesis.readthedocs.io
- Release availability
- The project describes publishing new packages to PyPI after changes are merged, usually within half an hour.Read 28 Sep 2026 · hypothesis.works
- Repeatable failures
- Hypothesis saves failing examples in a local test database so it can replay them when tests run again.Read 28 Sep 2026 · hypothesis.works
- Simplifies failures
- When Hypothesis finds a bug, it reports the simplest possible failing example.Read 29 Sep 2026 · hypothesis.works
- Stateful testing
- Rule-based state machines let Hypothesis generate sequences of operations to test stateful systems and objects.Read 28 Sep 2026 · hypothesis.works
- Test framework support
- Hypothesis works with pytest, unittest, nose, or another framework that can run a Python function.Read 28 Sep 2026 · hypothesis.works
- Test runner limitation
- Hypothesis is not itself a test runner; it works inside a user's normal testing framework.Read 28 Sep 2026 · hypothesis.works
- Test runners
- Hypothesis tests can run as regular Python functions and work with pytest or unittest.Read 29 Sep 2026 · hypothesis.readthedocs.io
- Thread safety
- As of version 6.136.9, Hypothesis supports running the same test simultaneously from multiple threads.Read 28 Sep 2026 · hypothesis.works
Strong points and limits
Strong points
- Generates inputs, including edge cases, from described properties.
- Attempts to simplify failing examples.
- Stores failures locally for replay.
- Rule-based state machines test sequences of operations.
Limits
- It is not a test runner.
- Only the most recent Hypothesis version is supported.
- Undocumented behavior may change in patch releases.
Who it suits
Hypothesis suits Python developers who want tests to explore inputs and edge cases based on described behavior. It works inside an existing test framework rather than replacing a test runner.
Verdict
Hypothesis adds generated-input exploration and failure replay to Python tests running in a separate framework. Its default is 100 examples per test, adjustable through max_examples.
Where Specifiction places it
- Property-Based Testing Tools#15 of 287.4