Skip to content

Commit

Permalink
try some more stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Zac-HD committed Aug 25, 2024
1 parent b4e5bed commit 2dd5577
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 12 deletions.
3 changes: 3 additions & 0 deletions hypothesis-python/RELEASE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
RELEASE_TYPE: patch

This patch makes some internal changes for compatibility with Crosshair.
10 changes: 8 additions & 2 deletions hypothesis-python/src/hypothesis/internal/conjecture/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,9 @@ def test_function(self, data: ConjectureData) -> None:
# drive the ir tree through the test function to convert it
# to a buffer
initial_origin = data.interesting_origin
initial_traceback = getattr(data.extra_information, "_expected_traceback", None)
initial_traceback = getattr(
data.extra_information, "_expected_traceback", None
)
data = ConjectureData.for_ir_tree(data.examples.ir_tree_nodes)
self.__stoppable_test_function(data)
data.freeze()
Expand All @@ -527,7 +529,11 @@ def test_function(self, data: ConjectureData) -> None:
data.status.INVALID: "failed filters",
data.status.OVERRUN: "overran",
}[data.status]
wrapped_tb = "" if initial_traceback is None else textwrap.indent(initial_traceback, " | ")
wrapped_tb = (
""
if initial_traceback is None
else textwrap.indent(initial_traceback, " | ")
)
raise FlakyReplay(
f"Inconsistent results from replaying a failing test case!\n"
f"{wrapped_tb}on backend={self.settings.backend!r} but "
Expand Down
1 change: 1 addition & 0 deletions hypothesis-python/tests/cover/test_randoms.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ def test_randbytes_have_right_length(rnd, n):
assert len(rnd.randbytes(n)) == n


@pytest.mark.skipif(settings._current_profile == "crosshair", reason="takes hours")
@given(any_random)
def test_can_manage_very_long_ranges_with_step(rnd):
i = rnd.randrange(0, 2**256, 3)
Expand Down
4 changes: 3 additions & 1 deletion hypothesis-python/tests/cover/test_stateful.py
Original file line number Diff line number Diff line change
Expand Up @@ -1325,4 +1325,6 @@ def rule1(self, data):
assert data


TestLotsOfEntropyPerStepMachine = LotsOfEntropyPerStepMachine.TestCase
@pytest.mark.skipif(Settings._current_profile == "crosshair", reason="takes hours")
def test_lots_of_entropy():
run_state_machine_as_test(LotsOfEntropyPerStepMachine)
5 changes: 2 additions & 3 deletions hypothesis-python/tests/nocover/test_characters.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
import string
from encodings.aliases import aliases

from hypothesis import given, strategies as st
from hypothesis import settings
import pytest

from hypothesis import given, settings, strategies as st

from tests.common.utils import Why, xfail_on_crosshair

IDENTIFIER_CHARS = string.ascii_letters + string.digits + "_"
Expand Down Expand Up @@ -52,7 +52,6 @@ def _enc(cdc):
assert len(lots_of_encodings) > 100 # sanity-check



@pytest.mark.skipif(settings._current_profile == "crosshair", reason="takes 2000s")
@given(data=st.data(), codec=st.sampled_from(lots_of_encodings))
def test_can_constrain_characters_to_codec(data, codec):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@

from tests.common import standard_types
from tests.common.debug import minimal
from tests.common.utils import Why, xfail_on_crosshair


@xfail_on_crosshair(Why.floats, strict=False)
@pytest.mark.parametrize("spec", standard_types, ids=repr)
def test_can_collectively_minimize(spec):
n = 10
Expand Down
10 changes: 5 additions & 5 deletions hypothesis-python/tests/nocover/test_database_usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,15 @@ def condition(x):
assert len(all_values(database)) < original


@xfail_on_crosshair(Why.symbolic_outside_context)
def test_respects_max_examples_in_database_usage():
key = b"a database key"
database = InMemoryExampleDatabase()
do_we_care = True
counter = [0]
counter = 0

def check(x):
counter[0] += 1
nonlocal counter
counter += 1
return do_we_care and has_a_non_zero_byte(x)

def stuff():
Expand All @@ -138,9 +138,9 @@ def stuff():
stuff()
assert len(all_values(database)) > 10
do_we_care = False
counter[0] = 0
counter = 0
stuff()
assert counter == [10]
assert counter == 10


def test_does_not_use_database_when_seed_is_forced(monkeypatch):
Expand Down
1 change: 1 addition & 0 deletions hypothesis-python/tests/nocover/test_sampled_from.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ def test_flags_minimizes_bit_count():
)


@xfail_on_crosshair(Why.undiscovered)
def test_flags_finds_all_bits_set():
assert find_any(st.sampled_from(LargeFlag), lambda f: f == ~LargeFlag(0))

Expand Down
3 changes: 3 additions & 0 deletions hypothesis-python/tests/nocover/test_simple_numbers.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from hypothesis.strategies import floats, integers, lists

from tests.common.debug import minimal
from tests.common.utils import Why, xfail_on_crosshair


def test_minimize_negative_int():
Expand Down Expand Up @@ -116,6 +117,7 @@ def test_can_minimal_infinite_negative_float():
assert minimal(floats(), lambda x: x < -sys.float_info.max)


@xfail_on_crosshair(Why.floats)
def test_can_minimal_float_on_boundary_of_representable():
minimal(floats(), lambda x: x + 1 == x and not math.isinf(x))

Expand Down Expand Up @@ -153,6 +155,7 @@ def test_minimal_fractional_float():
assert minimal(floats(), lambda x: x >= 1.5) == 2


@xfail_on_crosshair(Why.undiscovered)
def test_minimizes_lists_of_negative_ints_up_to_boundary():
result = minimal(
lists(integers(), min_size=10),
Expand Down
2 changes: 1 addition & 1 deletion hypothesis-python/tests/numpy/test_from_dtype.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def test_is_t(x):
test_is_t()


@settings(max_examples=100)
@settings(max_examples=100, deadline=None)
@given(nps.nested_dtypes(max_itemsize=400), st.data())
def test_infer_strategy_from_dtype(dtype, data):
# Given a dtype
Expand Down

0 comments on commit 2dd5577

Please sign in to comment.