def test_can_truncate_template_record(): class Breakable(GenericStateMachine): counter_start = 0 def __init__(self): self.counter = type(self).counter_start def steps(self): return integers() def execute_step(self, step): self.counter += 1 if self.counter > 10: assert step < 0 runner = Breakable.find_breaking_runner() strat = StateMachineSearchStrategy() r = Random(1) simplifiers = list(strat.simplifiers(r, runner)) assert simplifiers assert any(u'convert_simplifier' in s.__name__ for s in simplifiers) while runner.record: runner.record.pop() assert not runner.record for s in simplifiers: for t in s(r, runner): pass
def test_can_shrink_deserialized_execution_without_running(machine): runner = machine.find_breaking_runner() strategy = StateMachineSearchStrategy() new_runner = strategy.from_basic(strategy.to_basic(runner)) r = Random(1) for simplifier in strategy.simplifiers(r, new_runner): try: next(simplifier(r, new_runner)) except StopIteration: pass
def test_can_serialize_statemachine_execution(machine): runner = machine.find_breaking_runner() strategy = StateMachineSearchStrategy() new_runner = strategy.from_basic(strategy.to_basic(runner)) with raises(AssertionError): new_runner.run(machine()) r = Random(1) for simplifier in strategy.simplifiers(r, new_runner): try: next(simplifier(r, new_runner)) except StopIteration: pass