From fbee318c1cb3227196a04d74d81affe6da7b4887 Mon Sep 17 00:00:00 2001 From: Zac Hatfield-Dodds Date: Tue, 8 Oct 2024 22:52:14 -0700 Subject: [PATCH] crosshair tweaks --- .../src/hypothesis/internal/conjecture/engine.py | 10 ++++++++-- hypothesis-python/tests/nocover/test_database_usage.py | 6 ++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/hypothesis-python/src/hypothesis/internal/conjecture/engine.py b/hypothesis-python/src/hypothesis/internal/conjecture/engine.py index 7013441358..7cf4e72ed8 100644 --- a/hypothesis-python/src/hypothesis/internal/conjecture/engine.py +++ b/hypothesis-python/src/hypothesis/internal/conjecture/engine.py @@ -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() @@ -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 " diff --git a/hypothesis-python/tests/nocover/test_database_usage.py b/hypothesis-python/tests/nocover/test_database_usage.py index 1b8040b8dd..ae029a5fe5 100644 --- a/hypothesis-python/tests/nocover/test_database_usage.py +++ b/hypothesis-python/tests/nocover/test_database_usage.py @@ -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, @@ -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()