def test_undo_error(self): """Checks undo a stack containing a failing action.""" stack = UndoableActionStack("meh", mergeable=False) action1 = mock.Mock(spec=UndoableAction) action1.expand.return_value = False action2 = mock.Mock(spec=UndoableAction) action2.expand.return_value = False action2.undo.side_effect = UndoError("meh") action3 = mock.Mock(spec=UndoableAction) stack.push(action1) stack.push(action2) stack.push(action3) self.assertRaises(UndoError, stack.undo) self.assertEqual(action1.undo.call_count, 0) self.assertEqual(action2.undo.call_count, 1) self.assertEqual(action3.undo.call_count, 1)
def testUndoError(self): """ Undo a stack containing a failing action. """ stack = UndoableActionStack("meh") action1 = mock.Mock(spec=UndoableAction) action2 = mock.Mock(spec=UndoableAction) action2.undo.side_effect = UndoError("meh") action3 = mock.Mock(spec=UndoableAction) stack.push(action1) stack.push(action2) stack.push(action3) self.assertRaises(UndoError, stack.undo) self.assertEqual(action1.undo.call_count, 0) self.assertEqual(action2.undo.call_count, 1) self.assertEqual(action3.undo.call_count, 1)
def undo_fail(self): raise UndoError("meh")