def do_draw(self, data): count = 0 while True: try: with self.limited_base.capped(self.max_leaves): return data.draw(self.strategy) except LimitReached: if count == 0: data.note_event(lazyformat( 'Draw for %r exceeded max_leaves ' 'and had to be retried', self,)) count += 1
def do_draw(self, data): count = 0 while True: try: with self.limited_base.capped(self.max_leaves): return data.draw(self.strategy) except LimitReached: # Workaround for possible coverage bug - this branch is definitely # covered but for some reason is showing up as not covered. if count == 0: # pragma: no branch data.note_event( lazyformat( "Draw for %r exceeded max_leaves and had to be retried", self, ) ) count += 1
def do_draw(self, data): for i in hrange(3): start_index = data.index value = data.draw(self.filtered_strategy) if self.condition(value): return value else: if i == 0: data.note_event(lazyformat( 'Retried draw from %r to satisfy filter', self,)) # This is to guard against the case where we consume no data. # As long as we consume data, we'll eventually pass or raise. # But if we don't this could be an infinite loop. assume(data.index > start_index) data.note_event('Aborted test because unable to satisfy %r' % ( self, )) data.mark_invalid()
def do_draw(self, data): # type: (ConjectureData) -> Ex for i in hrange(3): start_index = data.index value = data.draw(self.filtered_strategy) if self.condition(value): return value else: if i == 0: data.note_event( lazyformat("Retried draw from %r to satisfy filter", self)) # This is to guard against the case where we consume no data. # As long as we consume data, we'll eventually pass or raise. # But if we don't this could be an infinite loop. assume(data.index > start_index) data.note_event("Aborted test because unable to satisfy %r" % (self, )) data.mark_invalid() raise AssertionError("Unreachable, for Mypy") # pragma: no cover
def note_retried(self, data): data.note_event( lazyformat("Retried draw from %r to satisfy filter", self))
def note_retried(self, data): data.note_event(lazyformat("Retried draw from %r to satisfy filter", self))