Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
H

hypothesis

> 测试质量
Open source

The property-based testing library for Python

8.8K stars0 likes2 views
WebsiteGitHub

About

The property-based testing library for Python

Hypothesis

  • Website
  • Documentation
  • Source code
  • Contributing
  • Community

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 test case — 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 test case:

Failing test case: test_matches_builtin(ls=[0, 0])

Installation

To install Hypothesis:

bash
pip install hypothesis

There are also optional extras available.

Issues· 49 open

View all issuesOpen on GitHub
  • #4889

    Unintended error message raised when using `data().map(pack=str)`

    legibilityUpdated Sep 29, 2026
  • #4880

    test_assume_has_status_reason fails under the crosshair backend because of a CPython sys.monitoring bug

    tests/build/CIUpdated Sep 29, 2026
  • #4882

    Ghostwriter writes @given() for functions with no parameters

    Updated Sep 25, 2026
  • #4881

    Ghostwriter omits imports for filters built from annotated_types bounds

    Updated Sep 25, 2026
  • #4740

    Migrate the Hypothesis engine from Python to Rust

    internalsUpdated Sep 15, 2026
  • #4865

    Skill to migrate from pytest

    Updated Aug 17, 2026
  • #4849

    Improve django timezone library for modern standards

    interopUpdated Aug 12, 2026
  • #4495

    Ideas for more blog posts

    enhancementwebsiteUpdated Aug 1, 2026
  • #4309

    Documentation overhaul

    metadocsUpdated Jul 31, 2026
  • #4823

    Develop a strategy for symbolic backend support alongside rust-based hypothesis logic

    interopinternalsUpdated Jul 26, 2026

> Tags

Pythonfuzzingproperty-based-testingpythontesting

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 29, 2026
Category测试质量
PricingOpen source

> Related tools

J
Jest
JavaScript 测试框架
P
Playwright
现代端到端测试框架
E
eslint-plugin-test-selectors
Enforces that data-test-id attributes are added to interactive DOM elements (JSX) to help with UI testing. JSX only.