Closed galbino closed 1 month ago
Thanks for reporting @galbino!
This seems to be caused by our measuring of time spent in GC. A quick workaround may be to gc.disable()/gc.enable()
in the test context.
Maybe we should store a reference early to the real perfcounter
and use that.
I think it'd be reasonable to assign _perf_counter = time.perf_counter()
in here:
...it might be annoying to deal with our own monkeypatching, though maybe just doing from time import perf_counter
would let us skip the whole dance and just apply a different patch in that module?
I think I like your first proposal best, because even if it's more annoying it makes the why clear.
Let me throw up a patch to see just how annoying.
Hm, very annoying because how do we then test the gc accounting itself, ref test_should_not_fail_deadline_due_to_gc
.
Hi all. I have a function that I make use of
time.perf_counter()
to calculate latency, so I created an unit test patching that same function and addedside_effects
to the mock regarding the start and end time. For some time it worked perfectly, but after I updated hypothesis, this error started ocurring. From my investigation, it coincides with changes on the same file that it's happening and, from what I understand, the issue is that hypothesis is also usingtime.perf_counter()
but, for some reason, still inside the context where I'm mocking so it's crashing because there's no items left on my side_effect list.Here's a portion of code that I was able to reproduce the issue with:
Some info that might be helpful: Version with this problem: any version after 6.103.0 Python version: 3.11.1 File where it happens: hypothesis/internal/conjecture/junkdrawer.py:436 Error raised: