def test_extend_merge(self): history = UndoHistory() example = SimpleExample(str_value='foo', value=10) undo_item = UndoItem( object=example, name='str_value', old_value='foo', new_value='baz', ) history.add( UndoItem( object=example, name='str_value', old_value='foo', new_value='bar', )) with self.assertTraitDoesNotChange(history, 'undoable'): with self.assertTraitDoesNotChange(history, 'redoable'): history.extend(undo_item) self.assertEqual(history.now, 1) self.assertTrue(history.can_undo) self.assertFalse(history.can_redo) # XXX this is testing private state to ensure merge happened self.assertEqual(len(history.stack._stack), 1)
def test_extend(self): history = UndoHistory() example = SimpleExample(str_value='foo', value=10) undo_item = UndoItem( object=example, name='value', old_value=0, new_value=10, ) history.add( UndoItem( object=example, name='str_value', old_value='foo', new_value='bar', )) with self.assertTraitDoesNotChange(history, 'undoable'): with self.assertTraitDoesNotChange(history, 'redoable'): history.extend(undo_item) self.assertEqual(history.now, 1) self.assertTrue(history.can_undo) self.assertFalse(history.can_redo)