{"id":878,"library":"hypothesis","title":"Hypothesis","description":"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. This randomized testing can catch bugs and edge cases that you didn't think of and wouldn't have found. When Hypothesis finds a bug, it reports the simplest possible example. It is currently at version 6.151.10 and receives regular updates.","status":"active","version":"6.151.10","language":"python","source_language":"en","source_url":"https://github.com/HypothesisWorks/hypothesis","tags":["testing","property-based testing","fuzzing","unit testing"],"install":[{"cmd":"pip install hypothesis","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"note":"The primary decorator for property-based tests.","symbol":"given","correct":"from hypothesis import given"},{"note":"Commonly imported as 'st' for convenience to access built-in strategies.","symbol":"strategies","correct":"from hypothesis import strategies as st"}],"quickstart":{"code":"from hypothesis import given, strategies as st\n\ndef my_function(x):\n    return x + 1\n\n@given(st.integers())\ndef test_my_function_increments(n):\n    assert my_function(n) == n + 1\n\n# To run this, save as a Python file (e.g., example.py) and run with pytest\n# For manual execution, uncomment and call the function:\n# test_my_function_increments()","lang":"python","description":"This quickstart demonstrates a basic property-based test using Hypothesis. The `@given` decorator takes a strategy (here, `st.integers()`) and repeatedly calls the decorated test function with generated inputs, looking for counterexamples."},"warnings":[{"fix":"Refer to the official documentation and changelog before upgrading major versions or relying on undocumented features. Pin minor versions for stability in production.","message":"Documented APIs only guarantee backward compatibility across major version bumps. Undocumented attributes, modules, and behavior may include breaking changes in patch or minor releases. Always check the changelog for significant updates.","severity":"breaking","affected_versions":"All versions"},{"fix":"Pay attention to `HypothesisDeprecationWarning` messages and update your code to use the recommended alternatives to avoid breakage in future major releases.","message":"Deprecated features will emit a `HypothesisDeprecationWarning` for at least six months before being removed in a subsequent major release.","severity":"deprecated","affected_versions":"All versions"},{"fix":"Refactor data generation to be independent of test timings or other non-deterministic factors. Ensure that a given input always produces the same outcome during the test execution.","message":"Tests must have deterministic outcomes and data generation. If tests involve threads or other non-deterministic elements and data generation depends on timing, Hypothesis may report flaky failures.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Constrain strategies as much as possible to the domain relevant to your code. For instance, use `st.text(min_size=1, max_size=255, alphabet=string.ascii_letters)` instead of a generic `st.text()`.","message":"Using overly broad strategies (e.g., `st.text()` without length limits) can lead to extremely slow test runs, high memory consumption, or tests that struggle to find simple counterexamples due to the vast search space.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always use the `@given` decorator for defining property-based tests. `.example()` is for exploring what a strategy generates, not for testing assertions.","message":"The `.example()` method on strategies is intended for interactive use (e.g., in a REPL) and should not be used within test functions or production code.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-05-12T20:42:34.465Z","next_check":"2026-06-27T00:00:00.000Z","problems":[{"fix":"Ensure that all strategy functions are called with parentheses, even if they take no arguments (e.g., use `st.integers()` instead of `st.integers`).","cause":"This error occurs when a strategy function (e.g., `st.integers`) is passed to `@given` or another strategy combinator without being called, meaning the function itself is passed instead of the strategy it returns.","error":"hypothesis.errors.InvalidArgument: Expected SearchStrategy but got function"},{"fix":"Review your `assume()` and `.filter()` conditions to ensure they do not eliminate too many valid examples. Consider if your strategy definition allows for a sufficient range of inputs to satisfy your test's assumptions.","cause":"Hypothesis raises this error when it cannot find enough examples that satisfy the constraints imposed by `assume()` calls, `.filter()` methods, or an overly restrictive strategy definition, indicating that the conditions might be too hard or impossible to meet.","error":"hypothesis.errors.UnsatisfiableExample"},{"fix":"Explicitly provide a strategy for the type in question using `st.builds()` or ensure that the type hints are correct and Hypothesis has a registered strategy for that type.","cause":"This error occurs when Hypothesis attempts to automatically infer a strategy for a type, often in `builds()`, but fails to find a suitable mapping, particularly with custom types or when type annotations are missing or unresolvable.","error":"hypothesis.errors.ResolutionFailed: Could not resolve ... to a strategy"}],"ecosystem":"pypi","meta_description":null,"install_score":100,"install_tag":"verified","quickstart_score":null,"quickstart_tag":null,"pypi_latest":"6.152.6","cli_name":"hypothesis","cli_version":"","install_checks":{"last_tested":"2026-05-12","tag":"verified","tag_description":"installs cleanly on critical runtimes, fast import, recently tested","installed_version":"6.141.1","pypi_latest":"6.152.6","is_stale":true,"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"hypothesis","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.55,"mem_mb":14.2,"disk_size":"21.9M"},{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"hypothesis","exit_code":0,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":0.61,"mem_mb":14.2,"disk_size":"21.8M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"hypothesis","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":2.3,"import_time_s":0.42,"mem_mb":14.2,"disk_size":"22M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"hypothesis","exit_code":0,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":0.39,"mem_mb":14.2,"disk_size":"22M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"hypothesis","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.77,"mem_mb":14.5,"disk_size":"24.1M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"hypothesis","exit_code":0,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":0.82,"mem_mb":14.4,"disk_size":"24.0M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"hypothesis","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":2.2,"import_time_s":0.68,"mem_mb":14.5,"disk_size":"25M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"hypothesis","exit_code":0,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":0.66,"mem_mb":14.4,"disk_size":"25M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"hypothesis","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.97,"mem_mb":14.3,"disk_size":"15.8M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"hypothesis","exit_code":0,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":0.99,"mem_mb":14.3,"disk_size":"15.7M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"hypothesis","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":1.9,"import_time_s":0.9,"mem_mb":14.3,"disk_size":"16M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"hypothesis","exit_code":0,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":0.92,"mem_mb":14.3,"disk_size":"16M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"hypothesis","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.94,"mem_mb":15.3,"disk_size":"15.5M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"hypothesis","exit_code":0,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":1,"mem_mb":15.2,"disk_size":"15.4M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"hypothesis","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":1.9,"import_time_s":0.88,"mem_mb":15.3,"disk_size":"16M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"hypothesis","exit_code":0,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":0.99,"mem_mb":15.2,"disk_size":"16M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"hypothesis","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.61,"mem_mb":14.1,"disk_size":"21.9M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"hypothesis","exit_code":0,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":0.6,"mem_mb":14.1,"disk_size":"21.9M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"hypothesis","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":2.8,"import_time_s":0.53,"mem_mb":14.1,"disk_size":"22M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"hypothesis","exit_code":0,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":0.5,"mem_mb":14.1,"disk_size":"22M"}]},"quickstart_checks":{"last_tested":"2026-04-24","tag":null,"tag_description":null,"results":[{"runtime":"python:3.10-alpine","exit_code":0},{"runtime":"python:3.10-slim","exit_code":0},{"runtime":"python:3.11-alpine","exit_code":0},{"runtime":"python:3.11-slim","exit_code":0},{"runtime":"python:3.12-alpine","exit_code":0},{"runtime":"python:3.12-slim","exit_code":0},{"runtime":"python:3.13-alpine","exit_code":0},{"runtime":"python:3.13-slim","exit_code":0},{"runtime":"python:3.9-alpine","exit_code":0},{"runtime":"python:3.9-slim","exit_code":0}]}}