Skip to content

Commit

Permalink
helpful prints
Browse files Browse the repository at this point in the history
  • Loading branch information
reaganjlee committed Aug 19, 2024
1 parent cc2d5b2 commit 29916b3
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions hypothesis-python/src/hypothesis/stateful.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,16 +153,20 @@ def output(s):
must_stop = None
if steps_run >= max_steps:
must_stop = True
print("TESTING: must_stop 1")
elif steps_run <= _min_steps:
must_stop = False
print("TESTING: must_stop 2")
elif cd._bytes_drawn > (0.8 * BUFFER_SIZE):
# Better to stop after fewer steps, than always overrun and retry.
# See https://github.com/HypothesisWorks/hypothesis/issues/3618
must_stop = True
print("TESTING: must_stop 3")

start_draw = perf_counter()
start_gc = gc_cumulative_time()
if cd.draw_boolean(p=2**-16, forced=must_stop):
print(f"TESTING: ENDING, must_stop={must_stop}")
break
steps_run += 1

Expand Down Expand Up @@ -190,6 +194,7 @@ def output(s):
data_to_print = {
k: machine._pretty_print(v) for k, v in data.items()
}
print("TESTING: data_to_print", data_to_print)

# Assign 'result' here in case executing the rule fails below
result = multiple()
Expand All @@ -201,13 +206,15 @@ def output(s):
elif isinstance(v, list) and all(
isinstance(item, VarReference) for item in v
):



print(
"TESTING: varreference list",
[machine.names_to_values[item.name] for item in v],
)

data[k] = [machine.names_to_values[item.name] for item in v]


print("TESTING: data", data)
label = f"execute:rule:{rule.function.__name__}"
start = perf_counter()
start_gc = gc_cumulative_time()
Expand Down Expand Up @@ -236,9 +243,14 @@ def output(s):
# If it does, and the result is a 'MultipleResult',
# then 'print_step' prints a multi-variable assignment.
output(machine._repr_step(rule, data_to_print, result))
print(
"TESTING: print output",
machine._repr_step(rule, data_to_print, result),
)
machine.check_invariants(settings, output, cd._stateful_run_times)
cd.stop_example()
finally:
print("TESTING: TEARDOWN started")
output("state.teardown()")
machine.teardown()

Expand Down

0 comments on commit 29916b3

Please sign in to comment.