Exemplo n.º 1
0
 def test_list_append(self):
     model = [0, 1, 2, 3]
     um = UndoManager()
     proxy = um.setModel(model)
     with um.changeSet(title="list test"):
         proxy.append("a")
         proxy.append("b")
     assert len(um.undoStack) == 1
     assert len(um.redoStack) == 0
     assert model == [0, 1, 2, 3, "a", "b"]
     for a, b in zip(model, proxy):
         assert a == b
     assert um.undoInfo() == {"title": "list test"}
     assert um.redoInfo() is None
     assert len(um.undoStack) == 1
     assert len(um.redoStack) == 0
     um.undo()
     assert um.undoInfo() is None
     assert um.redoInfo() == {"title": "list test"}
     assert len(um.undoStack) == 0
     assert len(um.redoStack) == 1
     assert model == [0, 1, 2, 3]
     um.redo()
     assert model == [0, 1, 2, 3, "a", "b"]
     with pytest.raises(UndoManagerError):
         um.redo()
Exemplo n.º 2
0
 def test_undoInfo(self):
     model = [1, "a", "Q"]
     um = UndoManager()
     proxy = um.setModel(model)
     assert um.undoInfo() is None
     assert um.redoInfo() is None
     with um.changeSet(title="undo action", more="any info"):
         proxy[1] = 2000
     assert um.undoInfo() == {'more': 'any info', 'title': 'undo action'}
     assert um.redoInfo() is None
     um.undo()
     assert um.undoInfo() is None
     assert um.redoInfo() == {'more': 'any info', 'title': 'undo action'}
     um.redo()
     assert um.undoInfo() == {'more': 'any info', 'title': 'undo action'}
     assert um.redoInfo() is None
     um.undo()
     assert um.undoInfo() is None
     with um.changeSet(title="another"):
         proxy[1] = 2000
     assert um.undoInfo() == {'title': 'another'}
     assert um.redoInfo() is None