Skip to content

Commit 755486a

Browse files
committed
Mark failures for crosshair to fix?
1 parent c8a5cea commit 755486a

22 files changed

+51
-10
lines changed

hypothesis-python/tests/common/utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ class Why(enum.Enum):
257257
# Some are crosshair issues, some hypothesis issues, others truly ok-to-xfail tests.
258258
symbolic_outside_context = "CrosshairInternal error (using value outside context)"
259259
nested_given = "nested @given decorators don't work with crosshair"
260+
undiscovered = "crosshair may not find the failing input"
260261
other = "reasons not elsewhere categorized"
261262

262263

@@ -269,7 +270,7 @@ def xfail_on_crosshair(why: Why, /, *, strict=True, as_marks=False):
269270

270271
current_backend = settings.get_profile(settings._current_profile).backend
271272
kw = {
272-
"strict": strict,
273+
"strict": strict and why != Why.undiscovered,
273274
"reason": f"Expected failure due to: {why.value}",
274275
"condition": current_backend == "crosshair",
275276
}

hypothesis-python/tests/cover/test_datetimes.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from hypothesis.strategies import dates, datetimes, timedeltas, times
1717

1818
from tests.common.debug import assert_simple_property, find_any, minimal
19+
from tests.common.utils import Why, xfail_on_crosshair
1920

2021

2122
def test_can_find_positive_delta():
@@ -104,6 +105,7 @@ def test_single_date(val):
104105
assert find_any(dates(val, val)) is val
105106

106107

108+
@xfail_on_crosshair(Why.undiscovered)
107109
def test_can_find_midnight():
108110
find_any(times(), lambda x: x.hour == x.minute == x.second == 0)
109111

hypothesis-python/tests/cover/test_direct_strategies.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from hypothesis.vendor.pretty import pretty
2424

2525
from tests.common.debug import check_can_generate_examples, minimal
26+
from tests.common.utils import Why, xfail_on_crosshair
2627

2728
# Use `pretty` instead of `repr` for building test names, so that set and dict
2829
# parameters print consistently across multiple worker processes with different
@@ -437,6 +438,7 @@ def test_decimals():
437438
assert minimal(st.decimals(), lambda f: f.is_finite() and f >= 1) == 1
438439

439440

441+
@xfail_on_crosshair(Why.undiscovered)
440442
def test_non_float_decimal():
441443
minimal(st.decimals(), lambda d: d.is_finite() and decimal.Decimal(float(d)) != d)
442444

hypothesis-python/tests/cover/test_filter_rewriting.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ def test_rewrite_unsatisfiable_filter(s, pred):
182182
assert s.filter(pred).is_empty
183183

184184

185+
@xfail_on_crosshair(Why.undiscovered)
185186
@pytest.mark.parametrize(
186187
"pred",
187188
[

hypothesis-python/tests/cover/test_lookup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -876,6 +876,7 @@ def test_supportsop_types_support_protocol(protocol, data):
876876
assert issubclass(type(value), protocol)
877877

878878

879+
@xfail_on_crosshair(Why.undiscovered)
879880
@pytest.mark.parametrize("restrict_custom_strategy", [True, False])
880881
def test_generic_aliases_can_be_conditionally_resolved_by_registered_function(
881882
restrict_custom_strategy,

hypothesis-python/tests/cover/test_reproduce_failure.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ def test(data):
175175
assert "@reproduce_failure" not in o.getvalue()
176176

177177

178+
@xfail_on_crosshair(Why.undiscovered)
178179
def test_does_not_print_reproduction_for_large_data_examples_by_default():
179180
@settings(phases=no_shrink, print_blob=False)
180181
@given(st.data())

hypothesis-python/tests/cover/test_sampled_from.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ def stupid_sampled_sets(draw):
141141
return result
142142

143143

144+
@xfail_on_crosshair(Why.undiscovered)
144145
@given(stupid_sampled_sets())
145146
def test_efficient_sets_of_samples_with_chained_transformations_slow_path(x):
146147
# This deliberately exercises the standard filtering logic without going

hypothesis-python/tests/cover/test_stateful.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,6 +1285,7 @@ def fail_fast(self, a1, a2, a3, b1, b2, b3):
12851285
)
12861286

12871287

1288+
@xfail_on_crosshair(Why.undiscovered)
12881289
def test_multiple_common_targets():
12891290
class Machine(RuleBasedStateMachine):
12901291
a = Bundle("a")

hypothesis-python/tests/cover/test_targeting.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
from hypothesis.control import current_build_context
1717
from hypothesis.errors import InvalidArgument
1818

19+
from tests.common.utils import Why, xfail_on_crosshair
20+
1921

2022
@example(0.0, "this covers the branch where context.data is None")
2123
@given(
@@ -100,6 +102,7 @@ def test_cannot_target_same_label_twice(_):
100102
target(1.0, label="label")
101103

102104

105+
@xfail_on_crosshair(Why.undiscovered)
103106
@given(st.none())
104107
def test_cannot_target_default_label_twice(_):
105108
target(0.0)

hypothesis-python/tests/cover/test_testdecorators.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ def test_can_be_given_keyword_args(x, name):
149149
assert len(name) < x
150150

151151

152+
@xfail_on_crosshair(Why.undiscovered)
152153
@fails
153154
@given(one_of(floats(), booleans()), one_of(floats(), booleans()))
154155
def test_one_of_produces_different_values(x, y):
@@ -196,6 +197,7 @@ def test_removing_an_element_from_a_unique_list(xs, y):
196197
assert y not in xs
197198

198199

200+
@xfail_on_crosshair(Why.undiscovered)
199201
@fails
200202
@given(lists(integers(), min_size=2), data())
201203
def test_removing_an_element_from_a_non_unique_list(xs, data):
@@ -219,6 +221,7 @@ def test_can_mix_sampling_with_generating(x, y):
219221
assert type(x) == type(y)
220222

221223

224+
@xfail_on_crosshair(Why.undiscovered)
222225
@fails
223226
@given(frozensets(integers()))
224227
def test_can_find_large_sum_frozenset(xs):

hypothesis-python/tests/datetime/test_dateutil_timezones.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ def test_dateutil_exists_our_not_exists_are_inverse(value):
109109
assert datetime_does_not_exist(value) == (not tz.datetime_exists(value))
110110

111111

112+
@xfail_on_crosshair(Why.undiscovered)
112113
def test_datetimes_can_exclude_imaginary():
113114
find_any(
114115
datetimes(**DAY_WITH_IMAGINARY_HOUR_KWARGS, allow_imaginary=True),
@@ -120,6 +121,7 @@ def test_datetimes_can_exclude_imaginary():
120121
)
121122

122123

124+
@xfail_on_crosshair(Why.undiscovered)
123125
@fails_with(FailedHealthCheck)
124126
@given(
125127
datetimes(

hypothesis-python/tests/datetime/test_pytz_timezones.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ def test_time_bounds_must_be_naive(name, val):
104104
times(**{name: val}).validate()
105105

106106

107+
@xfail_on_crosshair(Why.undiscovered)
107108
@pytest.mark.parametrize(
108109
"bound",
109110
[

hypothesis-python/tests/datetime/test_zoneinfo_timezones.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,14 @@
1717
from hypothesis.errors import InvalidArgument
1818

1919
from tests.common.debug import assert_no_examples, find_any, minimal
20+
from tests.common.utils import Why, xfail_on_crosshair
2021

2122

2223
def test_utc_is_minimal():
2324
assert minimal(st.timezones()) is zoneinfo.ZoneInfo("UTC")
2425

2526

27+
@xfail_on_crosshair(Why.undiscovered)
2628
def test_can_generate_non_utc():
2729
find_any(
2830
st.datetimes(timezones=st.timezones()).filter(lambda d: d.tzinfo.key != "UTC")

hypothesis-python/tests/nocover/test_characters.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
from hypothesis import given, settings, strategies as st
1717

18+
from tests.common.utils import Why, xfail_on_crosshair
19+
1820
IDENTIFIER_CHARS = string.ascii_letters + string.digits + "_"
1921

2022

@@ -23,6 +25,7 @@ def test_large_blacklist(c):
2325
assert c not in IDENTIFIER_CHARS
2426

2527

28+
@xfail_on_crosshair(Why.symbolic_outside_context) # seems like a crosshair bug here
2629
@given(st.data())
2730
def test_arbitrary_blacklist(data):
2831
blacklist = data.draw(st.text(st.characters(max_codepoint=1000), min_size=1))

hypothesis-python/tests/nocover/test_database_usage.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ def has_a_non_zero_byte(x):
3232
return any(bytes(x))
3333

3434

35+
@xfail_on_crosshair(Why.undiscovered)
3536
def test_saves_incremental_steps_in_database():
3637
key = b"a database key"
3738
database = InMemoryExampleDatabase()

hypothesis-python/tests/nocover/test_duplication.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
from hypothesis import given, settings
1616
from hypothesis.strategies._internal import SearchStrategy
1717

18+
from tests.common.utils import Why, xfail_on_crosshair
19+
1820

1921
class Blocks(SearchStrategy):
2022
def __init__(self, n):
@@ -37,6 +39,7 @@ def test(b):
3739
assert set(counts.values()) == {1}
3840

3941

42+
@xfail_on_crosshair(Why.other, strict=False) # CrosshairInternal for n>0
4043
@pytest.mark.parametrize("n", range(1, 5))
4144
def test_mostly_does_not_duplicate_blocks_even_when_failing(n):
4245
counts = Counter()

hypothesis-python/tests/nocover/test_flatmap.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
)
2727

2828
from tests.common.debug import find_any, minimal
29+
from tests.common.utils import Why, xfail_on_crosshair
2930

3031
ConstantLists = integers().flatmap(lambda i: lists(just(i)))
3132

@@ -47,15 +48,13 @@ def test_in_order(x):
4748
assert x[0] < x[1]
4849

4950

51+
# crosshair just generates increasingly-long lists of [0.0]
52+
@xfail_on_crosshair(Why.undiscovered)
5053
def test_flatmap_retrieve_from_db():
51-
constant_float_lists = floats(0, 1).flatmap(lambda x: lists(just(x)))
52-
5354
track = []
5455

55-
db = ExampleDatabase()
56-
57-
@given(constant_float_lists)
58-
@settings(database=db)
56+
@given(floats(0, 1).flatmap(lambda x: lists(just(x))))
57+
@settings(database=ExampleDatabase())
5958
def record_and_test_size(xs):
6059
if sum(xs) >= 1:
6160
track.append(xs)
@@ -98,6 +97,7 @@ def criterion(ls):
9897
assert set(result) == {False, ""}
9998

10099

100+
@xfail_on_crosshair(Why.undiscovered) # for n >= 8 at least
101101
@pytest.mark.parametrize("n", range(1, 10))
102102
def test_can_shrink_through_a_binding(n):
103103
bool_lists = integers(0, 100).flatmap(
@@ -106,6 +106,7 @@ def test_can_shrink_through_a_binding(n):
106106
assert minimal(bool_lists, lambda x: x.count(True) >= n) == [True] * n
107107

108108

109+
@xfail_on_crosshair(Why.undiscovered) # for n >= 8 at least
109110
@pytest.mark.parametrize("n", range(1, 10))
110111
def test_can_delete_in_middle_of_a_binding(n):
111112
bool_lists = integers(1, 100).flatmap(

hypothesis-python/tests/nocover/test_floating.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from hypothesis.strategies import data, floats, lists
2121

2222
from tests.common.debug import find_any
23-
from tests.common.utils import fails
23+
from tests.common.utils import Why, fails, xfail_on_crosshair
2424

2525
TRY_HARDER = settings(
2626
max_examples=1000, suppress_health_check=[HealthCheck.filter_too_much]
@@ -93,6 +93,7 @@ def test_is_not_int(x):
9393
assert x != int(x)
9494

9595

96+
@xfail_on_crosshair(Why.undiscovered)
9697
@fails
9798
@given(floats())
9899
@TRY_HARDER
@@ -128,6 +129,7 @@ def test_floats_are_in_range(x, y, data):
128129
assert x <= t <= y
129130

130131

132+
@xfail_on_crosshair(Why.undiscovered)
131133
@pytest.mark.parametrize("neg", [False, True])
132134
@pytest.mark.parametrize("snan", [False, True])
133135
def test_can_find_negative_and_signaling_nans(neg, snan):

hypothesis-python/tests/nocover/test_recursive.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from hypothesis import HealthCheck, given, settings, strategies as st
1818

1919
from tests.common.debug import find_any, minimal
20-
from tests.common.utils import flaky
20+
from tests.common.utils import Why, flaky, xfail_on_crosshair
2121

2222

2323
def test_can_generate_with_large_branching():
@@ -79,6 +79,7 @@ def test_drawing_many_near_boundary():
7979
assert len(ls) == size
8080

8181

82+
@xfail_on_crosshair(Why.undiscovered)
8283
def test_can_use_recursive_data_in_sets():
8384
nested_sets = st.recursive(st.booleans(), st.frozensets, max_leaves=3)
8485
find_any(nested_sets, settings=settings(deadline=None))

hypothesis-python/tests/nocover/test_regressions.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@
1414
from hypothesis._settings import note_deprecation
1515
from hypothesis.errors import HypothesisDeprecationWarning
1616

17+
from tests.common.utils import Why, xfail_on_crosshair
1718

19+
20+
@xfail_on_crosshair(Why.other)
1821
def test_note_deprecation_blames_right_code_issue_652():
1922
msg = "this is an arbitrary deprecation warning message"
2023

@@ -58,6 +61,8 @@ def test_unique_floats_with_nan_is_not_flaky_3926(ls):
5861

5962
# this will take a while to find the regression, but will eventually trigger it.
6063
# min_value=0 is critical to trigger the probing behavior which exhausts our buffer.
64+
# https://github.com/pschanely/CrossHair/issues/285 for an upstream fix.
65+
@xfail_on_crosshair(Why.other, strict=False)
6166
@given(st.integers(min_value=0, max_value=1 << 25_000))
6267
def test_overrun_during_datatree_simulation_3874(n):
6368
pass

hypothesis-python/tests/nocover/test_sampled_from.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from hypothesis.strategies._internal.strategies import SampledFromStrategy
2222

2323
from tests.common.debug import find_any, minimal
24-
from tests.common.utils import fails_with
24+
from tests.common.utils import Why, fails_with, xfail_on_crosshair
2525

2626

2727
@pytest.mark.parametrize("size", [100, 10**5, 10**6, 2**25])
@@ -101,6 +101,7 @@ def test_flag_enum_repr_uses_class_not_a_list():
101101
assert lazy_repr == "sampled_from(tests.nocover.test_sampled_from.AFlag)"
102102

103103

104+
@xfail_on_crosshair(Why.undiscovered)
104105
def test_exhaustive_flags():
105106
# Generate powerset of flag combinations. There are only 2^3 of them, so
106107
# we can reasonably expect that they are all are found.

hypothesis-python/tests/nocover/test_simple_numbers.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from hypothesis.strategies import floats, integers, lists
1818

1919
from tests.common.debug import minimal
20+
from tests.common.utils import Why, xfail_on_crosshair
2021

2122

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

118119

120+
@xfail_on_crosshair(Why.undiscovered) # sometimes
119121
def test_can_minimal_float_on_boundary_of_representable():
120122
minimal(floats(), lambda x: x + 1 == x and not math.isinf(x))
121123

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

155157

158+
@xfail_on_crosshair(Why.undiscovered)
156159
def test_minimizes_lists_of_negative_ints_up_to_boundary():
157160
result = minimal(
158161
lists(integers(), min_size=10),

0 commit comments

Comments
 (0)