Skip to content

Commit aa3b215

Browse files
committed
require make_testcase be passed frozen datas
1 parent 0ca16a9 commit aa3b215

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

hypothesis-python/src/hypothesis/core.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -675,6 +675,7 @@ def execute_explicit_examples(state, wrapped_test, arguments, kwargs, original_s
675675
"Falsifying example", "Falsifying explicit example", 1
676676
)
677677

678+
empty_data.freeze()
678679
tc = make_testcase(
679680
run_start=state._start_timestamp,
680681
property=state.test_identifier,
@@ -1302,6 +1303,7 @@ def _execute_once_for_engine(self, data: ConjectureData) -> None:
13021303
data._observability_args = {}
13031304
self._string_repr = "<backend failed to realize symbolic arguments>"
13041305

1306+
data.freeze()
13051307
tc = make_testcase(
13061308
run_start=self._start_timestamp,
13071309
property=self.test_identifier,
@@ -1498,6 +1500,7 @@ def run_engine(self):
14981500
# execute_once() will always raise either the expected error, or Flaky.
14991501
raise NotImplementedError("This should be unreachable")
15001502
finally:
1503+
ran_example.freeze()
15011504
# log our observability line for the final failing example
15021505
tc = make_testcase(
15031506
run_start=self._start_timestamp,
@@ -1521,11 +1524,7 @@ def run_engine(self):
15211524
f"{reproduction_decorator(falsifying_example.choices)} "
15221525
"as a decorator on your test case"
15231526
)
1524-
# Mostly useful for ``find`` and ensuring that objects that
1525-
# hold on to a reference to ``data`` know that it's now been
1526-
# finished and they can't draw more data from it.
1527-
ran_example.freeze() # pragma: no branch
1528-
# No branch is possible here because we never have an active exception.
1527+
15291528
_raise_to_user(
15301529
errors_to_report,
15311530
self.settings,
@@ -2096,6 +2095,7 @@ def fuzz_one_input(
20962095
raise
20972096
finally:
20982097
if TESTCASE_CALLBACKS:
2098+
data.freeze()
20992099
tc = make_testcase(
21002100
run_start=state._start_timestamp,
21012101
property=state.test_identifier,

hypothesis-python/src/hypothesis/internal/observability.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,10 @@ def make_testcase(
265265
from hypothesis.core import reproduction_decorator
266266
from hypothesis.internal.conjecture.data import Status
267267

268+
# We should only be sending observability reports for datas that have finished
269+
# being modified.
270+
assert data.frozen
271+
268272
if status_reason is not None:
269273
pass
270274
elif data.interesting_origin:

0 commit comments

Comments
 (0)