def test_two_undos(self, door_and_invoker): door, invoker = door_and_invoker invoker.activate(door) invoker.deactivate(door) for i in range(2): invoker.undo() assert not door.locked
def test_lots_of_undos(self, ninjas_and_invoker): ninjas, invoker = ninjas_and_invoker for i in range(30): invoker.activate(ninjas) invoker.deactivate(ninjas) for i in range(40): invoker.undo() assert not ninjas.armed
def test_undo_too_many_times(self, ninjas_and_invoker): ninjas, invoker = ninjas_and_invoker with pytest.raises(Exception): invoker.undo()
def test_off_undo(self, toaster_and_invoker): toaster, invoker = toaster_and_invoker toaster.on() invoker.deactivate(toaster) invoker.undo() assert toaster.is_on
def test_on_undo(self, toaster_and_invoker): toaster, invoker = toaster_and_invoker invoker.activate(toaster) invoker.undo() assert not toaster.is_on