Skip to content

Commit 958f37e

Browse files
committed
Move ensure_free_stackframes as closer to the actual test fn
1 parent d70db80 commit 958f37e

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

hypothesis-python/src/hypothesis/core.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,12 @@ def execute_once(
823823
self._string_repr = ""
824824
text_repr = None
825825
if self.settings.deadline is None and not TESTCASE_CALLBACKS:
826-
test = self.test
826+
827+
@proxies(self.test)
828+
def test(*args, **kwargs):
829+
with ensure_free_stackframes():
830+
return self.test(*args, **kwargs)
831+
827832
else:
828833

829834
@proxies(self.test)
@@ -833,7 +838,8 @@ def test(*args, **kwargs):
833838
arg_gctime = gc_cumulative_time()
834839
start = time.perf_counter()
835840
try:
836-
result = self.test(*args, **kwargs)
841+
with ensure_free_stackframes():
842+
result = self.test(*args, **kwargs)
837843
finally:
838844
finish = time.perf_counter()
839845
in_drawtime = math.fsum(data.draw_times.values()) - arg_drawtime

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,9 @@ def __stoppable_test_function(self, data: ConjectureData) -> None:
299299
"""
300300
# We ensure that the test has this much stack space remaining, no
301301
# matter the size of the stack when called, to de-flake RecursionErrors
302-
# (#2494, #3671).
302+
# (#2494, #3671). Note, this covers the data generation part of the test;
303+
# the actual test execution is additionally protected at the call site
304+
# in hypothesis.core.execute_once.
303305
with ensure_free_stackframes():
304306
try:
305307
self._test_function(data)

0 commit comments

Comments
 (0)