Skip to main content

hypothesis-crosshair

Downloads

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

0.0.32

  • Support the upcoming CrossHair release (after 0.0.113). Without this update, most tests will fail with nondeterminism errors under that release.
  • Drop support for Python 3.9, and add support for Python 3.15.
  • Follow the probability p that Hypothesis passes to draw_boolean, instead of CrossHair's default (which favors False). Collections drawn by CrossHair are no longer biased toward being short.

0.0.31

  • Set HYPOTHESIS_CROSSHAIR_MAX_UNINTERESTING_ITERATIONS to stop symbolic exploration once that many consecutive iterations have reached no new code locations. Hypothesis then runs its remaining examples (up to max_examples) with its normal random generation, so this does not bound total test time. Unset by default.

0.0.30

  • Avoid a spurious InvalidArgument error from hypothesis when CrossHair is generating imprecise symbolic floats. See details in this issue.

0.0.29

  • Fix a mismatch in time units used by CrossHair >= 0.0.106 and the plugin. Re-aligned and set minimum CrossHair version to 0.0.106.

0.0.28

  • Implement the replay_choices provider hook, letting Hypothesis warm-start CrossHair with high-coverage choice sequences (for example, a corpus found by HypoFuzz). Each enqueued sequence is handed to CrossHair's new smt_for_unification API, biasing the solver so that user-code branches taken under the seed are recorded in the search tree; follow-up (unseeded) iterations then explore the sibling branches the seed left unvisited. (fixes #26)

0.0.27

  • Prevent a NotDeterministic exception from escaping during post-test-run realization.

0.0.26

  • Ensure CrossHair respects the no-characters-allowed constraint (st.characters(alphabet="")). This strategy should now produce only the empty string. (previously CrossHair would allow it to produce any string)

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

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 of verified. 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

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.

Metadata

Release files for hypothesis-crosshair 0.0.32

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hypothesis-crosshair 0.0.32
File Size Uploaded Provenance Actions
hypothesis_crosshair-0.0.32.tar.gz 15.8 kB Without provenance Details for hypothesis_crosshair-0.0.32.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for hypothesis-crosshair 0.0.32
File Interpreter ABI Platform Actions
hypothesis_crosshair-0.0.32-py3-none-any.whl Python 3 none any Details for hypothesis_crosshair-0.0.32-py3-none-any.whl

Total release size: 33.7 kB

Release files / hypothesis_crosshair-0.0.32.tar.gz

Download URL hypothesis_crosshair-0.0.32.tar.gz
Size 15.8 kB
Tags Source
SHA-256 checksum
How to use checksums
9e56c5b92bc2891cba8d65f4180a8c75c7091e76333fb1326b625a426b28a71e
BLAKE2b-256 checksum
How to use checksums
b7342f3a79069a3e04b447024dd64d6a644b48e48de4d94cdd7ccad063205275
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Release files / hypothesis_crosshair-0.0.32-py3-none-any.whl

Download URL hypothesis_crosshair-0.0.32-py3-none-any.whl
Size 17.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ad0b5bbde7fc4350761c7bf69991ea19c9cc4e5a1bb31a1d2daa2e7c87c99970
BLAKE2b-256 checksum
How to use checksums
880ac92bb7fdac74beb0df9fc2b0fe2e50f12a292b29af7261f0e5329b868c76
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Security for hypothesis-crosshair 0.0.32

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.32 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page