{"library":"pytest-hypothesis","title":"pytest-hypothesis","description":"pytest-hypothesis is a bridge for using the Hypothesis property-based testing library with the pytest test framework. It enables developers to write tests that automatically generate varied inputs, helping to discover edge cases and subtle bugs in their code. While the `pytest-hypothesis` PyPI package is a legacy wrapper, its core functionality for pytest integration is now built directly into the main Hypothesis library (version 6.0.0 and later). It is actively maintained as part of Hypothesis, with a continuous release cadence.","language":"python","status":"active","last_verified":"Thu May 14","install":{"commands":["pip install hypothesis pytest"],"cli":null},"imports":["from hypothesis import given","from hypothesis import strategies as st"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"from hypothesis import given, strategies as st\nimport pytest\n\ndef add(a, b):\n    return a + b\n\n@given(st.integers(), st.integers())\ndef test_add_integers(a, b):\n    \"\"\"Test that addition is commutative and associative for integers.\"\"\"\n    assert add(a, b) == a + b\n    assert add(a, b) == add(b, a) # Commutativity\n    # Run this file with `pytest -v your_test_file.py`\n\n# Example of using assume() to filter inputs without failing the test\n@given(st.integers(min_value=1), st.integers(min_value=1))\ndef test_division_produces_float_or_int(numerator, denominator):\n    # Hypothesis generates pairs, but we might only care about certain conditions\n    # For instance, if we only want to test non-zero results, we can use assume\n    from hypothesis import assume\n    assume(denominator != 0)\n    result = numerator / denominator\n    assert isinstance(result, (float, int))\n    assert numerator == result * denominator\n","lang":"python","description":"This quickstart demonstrates how to use `hypothesis.given` decorator with `pytest`. Tests decorated with `@given` will be run multiple times by Hypothesis, with automatically generated inputs adhering to the specified strategies (e.g., `st.integers()`). Run these tests using the `pytest` command line tool.","tag":null,"tag_description":null,"last_tested":"2026-04-25","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}]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-14","installed_version":null,"pypi_latest":"10.0.3","is_stale":null,"summary":{"python_range":"3.10–3.9","success_rate":100,"avg_install_s":3.2,"avg_import_s":0.79,"wheel_type":"wheel"},"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.58,"mem_mb":14.2,"disk_size":"85.5M"},{"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.65,"mem_mb":14.2,"disk_size":"85.5M"},{"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":3.4,"import_time_s":0.42,"mem_mb":14.2,"disk_size":"157M"},{"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.49,"mem_mb":14.2,"disk_size":"157M"},{"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.75,"mem_mb":14.5,"disk_size":"93.8M"},{"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.89,"mem_mb":14.4,"disk_size":"93.8M"},{"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":3.1,"import_time_s":0.68,"mem_mb":14.5,"disk_size":"165M"},{"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.72,"mem_mb":14.4,"disk_size":"165M"},{"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.96,"mem_mb":14.3,"disk_size":"84.5M"},{"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":1.11,"mem_mb":14.3,"disk_size":"84.5M"},{"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":2.9,"import_time_s":0.91,"mem_mb":14.3,"disk_size":"156M"},{"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":1.08,"mem_mb":14.3,"disk_size":"156M"},{"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.98,"mem_mb":15.3,"disk_size":"81.2M"},{"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.1,"mem_mb":15.3,"disk_size":"81.0M"},{"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":2.9,"import_time_s":0.9,"mem_mb":15.3,"disk_size":"154M"},{"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":1.1,"mem_mb":15.3,"disk_size":"154M"},{"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.56,"mem_mb":14.1,"disk_size":"85.2M"},{"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.64,"mem_mb":14.1,"disk_size":"85.1M"},{"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":3.9,"import_time_s":0.51,"mem_mb":14.1,"disk_size":"157M"},{"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.75,"mem_mb":14.1,"disk_size":"157M"}]}}