Skip to content

Commit

Permalink
crosshair tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
Zac-HD committed Oct 9, 2024
1 parent fb91f66 commit fbee318
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
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 @@ -530,7 +530,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 = data.extra_information._expected_traceback # type: ignore
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 @@ -542,7 +544,11 @@ def test_function(self, data: ConjectureData) -> None:
data.status.INVALID: "failed filters",
data.status.OVERRUN: "overran",
}[data.status]
wrapped_tb = 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
6 changes: 6 additions & 0 deletions hypothesis-python/tests/nocover/test_database_usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
# v. 2.0. If a copy of the MPL was not distributed with this file, You can
# obtain one at https://mozilla.org/MPL/2.0/.

import pytest

from hypothesis import assume, core, find, given, settings, strategies as st
from hypothesis.database import (
ExampleDatabase,
Expand Down Expand Up @@ -103,6 +105,10 @@ def condition(x):
assert len(all_values(database)) < original


@pytest.mark.skipif(
settings._current_profile == "crosshair",
reason="condition is easy for crosshair, stops early",
)
def test_respects_max_examples_in_database_usage():
key = b"a database key"
database = InMemoryExampleDatabase()
Expand Down

0 comments on commit fbee318

Please sign in to comment.