Skip to main content

Hypothesis

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:

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,

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.

Metadata

Release files for hypothesis 6.138.15

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hypothesis 6.138.15
File Size Uploaded Provenance Actions
hypothesis-6.138.15.tar.gz 466.1 kB Without provenance Details for hypothesis-6.138.15.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for hypothesis 6.138.15
File Interpreter ABI Platform Actions
hypothesis-6.138.15-py3-none-any.whl Python 3 none any Details for hypothesis-6.138.15-py3-none-any.whl

Total release size: 999.7 kB

Release files / hypothesis-6.138.15.tar.gz

Download URL hypothesis-6.138.15.tar.gz
Size 466.1 kB
Tags Source
SHA-256 checksum
How to use checksums
6b0e1aa182eacde87110995a3543530d69ef411f642162a656efcd46c2823ad1
BLAKE2b-256 checksum
How to use checksums
3b68adc338edec178cf6c08b4843ea2b2d639d47bed4b06ea9331433b71acc0a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.18

Release files / hypothesis-6.138.15-py3-none-any.whl

Download URL hypothesis-6.138.15-py3-none-any.whl
Size 533.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b7cf743d461c319eb251a13c8e1dcf00f4ef7085e4ab5bf5abf102b2a5ffd694
BLAKE2b-256 checksum
How to use checksums
3949911eb0cd17884a7a6f510e78acf0a70592e414d194695a0c7c1db91645b2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.18

Security for hypothesis 6.138.15

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

6.138.15 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page