Skip to main content

Level-up your Hypothesis tests with CrossHair.

Project description

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

Next Version

  • Nothing yet

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hypothesis_crosshair-0.0.20.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

hypothesis_crosshair-0.0.20-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

Details for the file hypothesis_crosshair-0.0.20.tar.gz.

File metadata

  • Download URL: hypothesis_crosshair-0.0.20.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.21

File hashes

Hashes for hypothesis_crosshair-0.0.20.tar.gz
Algorithm Hash digest
SHA256 a26dca3eb5a0d2b5d3f095cb2809263c8fc8a64da8bdaada829096603d074b1d
MD5 410da7c05c75e934caa279519858cd0a
BLAKE2b-256 4c3ca38fdbffc48790f02360d86e9305e2603922a6939f214cfa079c0fcce4dc

See more details on using hashes here.

File details

Details for the file hypothesis_crosshair-0.0.20-py3-none-any.whl.

File metadata

File hashes

Hashes for hypothesis_crosshair-0.0.20-py3-none-any.whl
Algorithm Hash digest
SHA256 6b656543bb725649f531db5db2bfb964699f4e56c6e7522890c1776545a518a5
MD5 a64d51f6a8c2bb797f41f2a523a8d60f
BLAKE2b-256 5ad1c875e5629b66e89ce7b1ee25984112746c14216fd631cb020fcc9c60218c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page