From b156e7435c2f15f227696f5c8bc3a4b81f707c59 Mon Sep 17 00:00:00 2001 From: Zac Hatfield-Dodds Date: Sat, 29 Apr 2023 16:09:00 -0600 Subject: [PATCH] Fix inquisitor overrun This is rather rare, but happened --- .../src/hypothesis/internal/conjecture/shrinker.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/hypothesis-python/src/hypothesis/internal/conjecture/shrinker.py b/hypothesis-python/src/hypothesis/internal/conjecture/shrinker.py index 071e993c8a..4503804afd 100644 --- a/hypothesis-python/src/hypothesis/internal/conjecture/shrinker.py +++ b/hypothesis-python/src/hypothesis/internal/conjecture/shrinker.py @@ -546,10 +546,11 @@ def explain(self): ) # Turns out this was a variable-length part, so grab the infix... - if ( - result.status == Status.OVERRUN - or len(buf_attempt_fixed) != len(result.buffer) - or not result.buffer.endswith(buffer[end:]) + if result.status == Status.OVERRUN: + continue # pragma: no cover + if not ( + len(buf_attempt_fixed) == len(result.buffer) + and result.buffer.endswith(buffer[end:]) ): for ex, res in zip(shrink_target.examples, result.examples): assert ex.start == res.start @@ -612,8 +613,6 @@ def explain(self): # This *can't* be a shrink because none of the components were. assert shrink_target is self.shrink_target if result.status == Status.VALID: - # TODO: cover this branch. - # I might need to save or retrieve passing chunks too??? self.shrink_target.slice_comments[ (0, 0) ] = "The test sometimes passed when commented parts were varied together."