Test a sorting or parsing function against thousands of auto-generated inputs instead of writing each case by hand.
Find duplicate-handling or overflow bugs in custom data processing code by letting Hypothesis probe edge cases automatically.
Replace a slow hand-written fuzz test with a concise Hypothesis strategy that checks a property across many input shapes.
Add property-based tests to an existing pytest suite with one pip install and one decorator on a test function.
Hypothesis is a Python testing library based on an approach called property-based testing. In ordinary unit testing, a developer writes specific input values and checks that the code produces the expected output. With Hypothesis, you describe the shape of the inputs you want to test, such as "a list of integers," and the library automatically generates many random examples from that description and runs your test against all of them. The goal is to check that a property holds across a broad range of inputs rather than just the handful you thought to write by hand. This approach tends to find bugs that example-based tests miss, especially edge cases like empty lists, very large numbers, duplicate values, or unusual combinations that a developer might not think to try. In the README's example, a custom sorting function is tested by asking Hypothesis to generate random lists and verify that the custom function always produces the same result as Python's built-in sort. The test discovers that the custom function incorrectly removes duplicates, and Hypothesis reports the simplest possible failing input: a list containing two identical numbers. When Hypothesis finds a failure, it does not just report the first random example that broke the test. It automatically shrinks the failing input down to the smallest version that still triggers the bug. This makes the output easier to understand and debug compared to staring at a large random test case. Hypothesis is installed with a single pip command. Optional extras add support for additional data types and integrations. The library is primarily for Python, though the repository also contains ports to other languages. Documentation and community links are provided in the README.
← hypothesisworks on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.