HypothesisWorks

hypothesis: Find Bugs with Property-Based Testing

Hypothesis is a Python testing library that generates inputs for properties your code should satisfy. Use it to explore edge cases that example-based tests may miss and to get simplified failing cases when a bug is found.

View on GitHub Compare
Stars
9k
Forks
686
Stars, last 30 days
+78

Our take

Health score

75/100

How it is scored
Activity
90
Community
82
Issues
72
Pull requests
57

+78 stars in the last 30 days

  • Releases more often than 93% of the projects we track
  • Merges more pull requests than 80% of the projects we track
  • More contributors than 78% of the projects we track

Project history

Daily GitHub snapshots since Oct 7, 2026. History covers stars and forks; health signals are not tracked historically.

Selected snapshot

Stars

9,152

Forks

698

Change since Nov 9, 2026: +9 stars·-1 forks

Overview

Hypothesis helps Python developers test behavior across a range of inputs instead of writing a separate test case for each example. You describe the kinds of inputs to explore and the property that should hold, and the library generates test data, including edge cases.

When a generated case fails, Hypothesis can reduce it to a simpler example. This makes the failure easier to inspect and is useful both for finding bugs and understanding them.

Key Features

  • Generates test inputs from strategies that describe the values a test should examine.
  • Checks a declared property against randomly selected inputs.
  • Explores edge cases that may not be covered by manually chosen examples.
  • Shrinks failing inputs to simpler cases that help clarify the failure.
  • Integrates with Python tests through the @given decorator.
  • Offers optional extras for additional functionality.

Use Cases

  • Python developers can test functions that handle many possible inputs without maintaining a large collection of hand-written examples.
  • Library authors can check that APIs behave consistently across varied data, including boundary cases.
  • Developers working with collections or transformations can test general properties such as sorting behavior across generated lists.
  • Teams investigating a hard-to-reproduce bug can use a minimized failing input to make the problem easier to understand.

Getting Started

Install the package with:

pip install hypothesis

See the README and documentation for usage details and optional extras.

Considerations

Hypothesis tests properties you specify, so useful coverage depends on choosing meaningful properties and input strategies. Generated tests complement, rather than replace, examples and other testing methods. The repository input reports its license as NOASSERTION, so check the project’s licensing details before adopting it where a confirmed license is required.

Found this useful?

Share it with someone who would like hypothesis.