Level-up your Hypothesis tests with CrossHair.
Project Links
Meta
Author: Phillip Schanely
Requires Python: >=3.9
Classifiers
Development Status
- 2 - Pre-Alpha
Framework
- Hypothesis
Intended Audience
- Developers
License
- OSI Approved :: MIT License
Operating System
- OS Independent
Programming Language
- Python
- Python :: 3
- Python :: 3.8
- Python :: 3.9
- Python :: 3.10
- Python :: 3.11
- Python :: 3.12
- Python :: 3.13
Topic
- Software Development :: Testing
hypothesis-crosshair
Add the power of solver-based symbolic execution to your Hypothesis tests with CrossHair.
Just
pip install hypothesis-crosshair
and then add a backend="crosshair" setting, like so:
from hypothesis import given, settings, strategies as st
@settings(backend="crosshair")
@given(st.integers())
def test_needs_solver(x):
assert x != 123456789
Docs hopefully coming soon. In the meantime, start a discussion or file an issue.
FAQ
Can I try using crosshair for ALL my hypothesis tests?
Yes! Create or edit your pytest conftest.py file to register a profile like the following:
from hypothesis import settings
settings.register_profile(
"crosshair",
backend="crosshair",
)
And then run pytest using the profile you've defined:
pytest . --hypothesis-profile=crosshair
Changelog
Next Version
- Nothing yet
0.0.25
- Prevent internal crosshair errors from getting exposed while trying to recover from a user-level exception.
- Synchronize with recent hypothesis API updates. (fixes #40 and #42)
0.0.24
- Do not attempt to capture and retry hypothesis internal exceptions. (fixes #34)
0.0.23
- Prevent an incorrect verified claim under SMT-heavy analysis. (fixes pschanely/CrossHair#354)
0.0.22
- Abort concrete executions with invalid draws. (fixes #29)
- Adjust how the preventative measures in v0.0.21 work for recursive datastructures.
0.0.21
- Avoid occasional unexpected errors when stopping a test run with Ctrl-C.
- Prevent over-expansion when generating recursive datastructures. (fixes #27)
0.0.20
- Avoid potential import warning when registering ourself with hypothesis.
- Skip constraint checking when performing a concrete re-execution.
0.0.19
- Limit the re-thow behavior in 0.0.17 to Unsatisfiable errors exclusively
- Change default path timeout to 2.5 seconds
- Prevent false positives by ensuring user exceptions are only exposed under concrete executions.
0.0.18
- Ensure drawn floats respect hypothesis signed-zero semantics for min_value/max_value.
0.0.17
- Do not interpret Unsatisfiable errors as user exceptions; just re-throw, so that hypothesis can act appropriately.
- Report CrossHair path abortions to hypothesis as
discard_test_case
instead ofverified
. This lets Hypothesis report unsatisfiable strategies correctly when run under crosshair.
0.0.16
- Integrate hypothesis's new BackCannotProceed exception, which will reduce the likelihood of FlakeyReplay errors.
- Validate suspected counterexamples with concrete executions.
- Treat nondeterminism as an unexplored path rather than a user error. (though we might change this back later)
- Ensure realization logic called by hypothesis cannot grow the path tree.
- Allow for collapsing more SMT expressions when drawing strings and floats.
0.0.15
- (was never released)
0.0.14
- Support the revised hypothesis provider draw interfaces as of hypothesis
v6.112.0
.
0.0.13
- Integrate with the hypothesis observability system.
0.0.12
- Error early when trying to nest hypothesis tests. (which will otherwise put CrossHair into a bad state)
0.0.11
- Address errors when the solver can't keep up (fixes #20)
0.0.10
- Reduce the numebr of iterations required to generate valid datetimes
0.0.9
- Quietly ignore iterations that appear to be failing due to symbolic intolerance.
Aug 13, 2025
0.0.25
May 29, 2025
0.0.24
May 21, 2025
0.0.23
Apr 22, 2025
0.0.22
Apr 10, 2025
0.0.21
Jan 31, 2025
0.0.20
Jan 23, 2025
0.0.19
Oct 18, 2024
0.0.18
Oct 18, 2024
0.0.17
Oct 09, 2024
0.0.16
Sep 05, 2024
0.0.14
Aug 20, 2024
0.0.13
Aug 08, 2024
0.0.12
Aug 02, 2024
0.0.11
Jul 22, 2024
0.0.10
Jul 22, 2024
0.0.9
Jul 19, 2024
0.0.8
Jul 07, 2024
0.0.7
Jul 01, 2024
0.0.6
Jun 28, 2024
0.0.5
May 13, 2024
0.0.4
Mar 15, 2024
0.0.2
Mar 07, 2024
0.0.1