Skip to content

Commit fbee318

Browse files
committed
crosshair tweaks
1 parent fb91f66 commit fbee318

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

hypothesis-python/src/hypothesis/internal/conjecture/engine.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,9 @@ def test_function(self, data: ConjectureData) -> None:
530530
# drive the ir tree through the test function to convert it
531531
# to a buffer
532532
initial_origin = data.interesting_origin
533-
initial_traceback = data.extra_information._expected_traceback # type: ignore
533+
initial_traceback = getattr(
534+
data.extra_information, "_expected_traceback", None
535+
)
534536
data = ConjectureData.for_ir_tree(data.examples.ir_tree_nodes)
535537
self.__stoppable_test_function(data)
536538
data.freeze()
@@ -542,7 +544,11 @@ def test_function(self, data: ConjectureData) -> None:
542544
data.status.INVALID: "failed filters",
543545
data.status.OVERRUN: "overran",
544546
}[data.status]
545-
wrapped_tb = textwrap.indent(initial_traceback, " | ")
547+
wrapped_tb = (
548+
""
549+
if initial_traceback is None
550+
else textwrap.indent(initial_traceback, " | ")
551+
)
546552
raise FlakyReplay(
547553
f"Inconsistent results from replaying a failing test case!\n"
548554
f"{wrapped_tb}on backend={self.settings.backend!r} but "

hypothesis-python/tests/nocover/test_database_usage.py

+6
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
# v. 2.0. If a copy of the MPL was not distributed with this file, You can
99
# obtain one at https://mozilla.org/MPL/2.0/.
1010

11+
import pytest
12+
1113
from hypothesis import assume, core, find, given, settings, strategies as st
1214
from hypothesis.database import (
1315
ExampleDatabase,
@@ -103,6 +105,10 @@ def condition(x):
103105
assert len(all_values(database)) < original
104106

105107

108+
@pytest.mark.skipif(
109+
settings._current_profile == "crosshair",
110+
reason="condition is easy for crosshair, stops early",
111+
)
106112
def test_respects_max_examples_in_database_usage():
107113
key = b"a database key"
108114
database = InMemoryExampleDatabase()

0 commit comments

Comments
 (0)