Debian Codegraph @

hypothesis-python/tests/crosshair/test_conformance.py

raw
1 # This file is part of Hypothesis, which may be found at
2 # https://github.com/HypothesisWorks/hypothesis/
3 #
4 # Copyright the Hypothesis Authors.
5 # Individual contributors are listed in AUTHORS.rst and the git log.
6 #
7 # This Source Code Form is subject to the terms of the Mozilla Public License,
8 # v. 2.0. If a copy of the MPL was not distributed with this file, You can
9 # obtain one at https://mozilla.org/MPL/2.0/.
10
11 from crosshair.core import IgnoreAttempt, NotDeterministic, UnexploredPath
12 from hypothesis_crosshair_provider.crosshair_provider import CrossHairPrimitiveProvider
13
14 from hypothesis import Verbosity, settings, strategies as st
15 from hypothesis.internal.conjecture.provider_conformance import run_conformance_test
16
17
18 def test_provider_conformance_crosshair():
19 # Hypothesis can in theory pass values of any type to `realize`,
20 # but the default strategy in the conformance test here acts too much like a
21 # fuzzer for crosshair internals here and finds very strange errors.
22 _realize_objects = (
23 st.integers() | st.floats() | st.booleans() | st.binary() | st.text()
24 )
25 run_conformance_test(
26 CrossHairPrimitiveProvider,
27 context_manager_exceptions=(IgnoreAttempt, UnexploredPath, NotDeterministic),
28 settings=settings(
29 max_examples=5,
30 stateful_step_count=10,
31 # It's nice to set Verbosity.verbose unconditionally here so we get
32 # more information during rare errors without having to retry.
33 #
34 # Careful, though: it's possible interactions with crosshair differ
35 # under verbosity (eg realizing the symbolic debug messages), so
36 # some errors may only surface with or without verbosity.
37 verbosity=Verbosity.verbose,
38 ),
39 _realize_objects=_realize_objects,
40 )