File tree Expand file tree Collapse file tree 3 files changed +36
-0
lines changed Expand file tree Collapse file tree 3 files changed +36
-0
lines changed Original file line number Diff line number Diff line change 9
9
# obtain one at https://mozilla.org/MPL/2.0/.
10
10
11
11
import contextlib
12
+ import enum
12
13
import sys
13
14
from io import StringIO
14
15
from types import SimpleNamespace
@@ -228,3 +229,32 @@ def temp_registered(type_, strat_or_factory):
228
229
# config option, so *linking against* something built this way can break us.
229
230
# Everything is terrible
230
231
PYTHON_FTZ = next_down (sys .float_info .min ) == 0.0
232
+
233
+
234
+ class Why (enum .Enum ):
235
+ # Use an enum here so it's easier to find and/or exclude some cases later
236
+ other = "other"
237
+ flaky_replay = "Inconsistent results from replaying a failing test..."
238
+ symbolic_outside_context = (
239
+ "CrosshairInternal error from using value outside context"
240
+ )
241
+ undiscovered = "crosshair doesn't find the failing input"
242
+
243
+
244
+ def xfail_on_crosshair (why : Why , / ):
245
+ import pytest
246
+ try :
247
+ import crosshair .util
248
+ except ImportError :
249
+ return pytest .mark .xf_crosshair
250
+
251
+ kw = {
252
+ "strict" : True ,
253
+ "reason" : f"Expected failure due to: { why .value } " ,
254
+ "condition" : settings .get_profile (settings ._current_profile ).backend
255
+ == "crosshair" ,
256
+ }
257
+ if why is Why .symbolic_outside_context :
258
+ kw ["raises" ] = crosshair .util .CrosshairInternal
259
+
260
+ return lambda fn : pytest .mark .xf_crosshair (pytest .mark .xfail (** kw )(fn ))
Original file line number Diff line number Diff line change @@ -46,6 +46,7 @@ def pytest_configure(config):
46
46
"markers" ,
47
47
"xp_min_version(api_version): run when greater or equal to api_version" ,
48
48
)
49
+ config .addinivalue_line ("markers" , "xf_crosshair: selection for xfailing symbolics" )
49
50
50
51
51
52
def pytest_addoption (parser ):
Original file line number Diff line number Diff line change 30
30
)
31
31
32
32
from tests .common .utils import (
33
+ Why ,
33
34
assert_falsifying_output ,
34
35
capture_out ,
35
36
fails ,
36
37
fails_with ,
37
38
no_shrink ,
38
39
raises ,
39
40
skipif_emscripten ,
41
+ xfail_on_crosshair ,
40
42
)
41
43
42
44
# This particular test file is run under both pytest and nose, so it can't
@@ -304,6 +306,7 @@ def test_has_ascii(x):
304
306
assert any (c in ascii_characters for c in x )
305
307
306
308
309
+ @xfail_on_crosshair (Why .symbolic_outside_context )
307
310
def test_can_derandomize ():
308
311
values = []
309
312
@@ -393,6 +396,7 @@ def test_mixed_text(x):
393
396
assert set (x ).issubset (set ("abcdefg" ))
394
397
395
398
399
+ @xfail_on_crosshair (Why .other ) # runs ~five failing examples
396
400
def test_when_set_to_no_simplifies_runs_failing_example_twice ():
397
401
failing = []
398
402
@@ -478,6 +482,7 @@ def test_empty_lists(xs):
478
482
assert xs == []
479
483
480
484
485
+ @xfail_on_crosshair (Why .other ) # executes >> 2 tests, but there are only two bools
481
486
def test_given_usable_inline_on_lambdas ():
482
487
xs = []
483
488
given (booleans ())(lambda x : xs .append (x ))()
You can’t perform that action at this time.
0 commit comments