def test_setstack(self): 'Test that a new stack can be set' old = undo.stack() new = undo.Stack() undo.setstack(new) stack = undo.stack() assert stack is new assert stack is not old
def test_stack(self): 'Test that ``with group()`` diverts undo.stack()' undo.stack().clear() _Group = undo._Group('') stack = [] _Group._stack = stack assert undo.stack()._receiver == undo.stack()._undos assert undo.stack().undocount() == 0 with _Group: assert undo.stack()._receiver == stack assert undo.stack()._receiver == undo.stack()._undos assert undo.stack().undocount() == 1 assert stack == [] assert undo.stack()._undos == deque([_Group])
def test_savepoint(self): 'Test that savepoint behaves correctly.' undo.stack()._undos = deque([1, 2]) assert undo.stack().haschanged() undo.stack().savepoint() assert not undo.stack().haschanged() undo.stack()._undos.pop() assert undo.stack().haschanged()
def test_undo_resets_redos(self): 'Calling undo clears any available redos.' undo.stack()._undos = deque([1, 2, 3]) undo.stack()._redos = deque([4, 5, 6]) undo.stack()._receiver = undo.stack()._undos undo.stack().append(7) assert undo.stack()._undos == deque([1, 2, 3, 7]) assert undo.stack()._redos == deque([])
def test_group_multiple_undo(self): 'Test that calling undo after a group undoes all actions.' @undo.undoable def add(seq, v): seq.append(v) yield 'add' seq.pop() l = [] with undo.group('desc'): for i in range(3): add(l, i) assert l == [0, 1, 2], l assert undo.stack().undocount() == 1 undo.stack().undo() assert undo.stack().undocount() == 0 assert l == [], l
def test_undo_changes_stacks(self): 'Calling undo updates both the undos and redos stacks.' undo.stack()._undos = deque([1, 2, self.action]) undo.stack()._redos = deque([4, 5, 6]) undo.stack().undo() assert undo.stack()._undos == deque([1, 2]) assert undo.stack()._redos == deque([4, 5, 6, self.action])
import sys from PyQt4 import QtCore, QtGui, uic import PyQt4 import charOps as co import dataFiles import random import numpy as np import pyqtgraph as pg import bbc import json import bbcode import actionNodes as nodes from datetime import datetime import undo stack = undo.stack() #define color vars colorStat = dataFiles.PrintColors['stats'] colorName = dataFiles.PrintColors['names'] colorWarn = dataFiles.PrintColors['warn'] colorGood = dataFiles.PrintColors['good'] def showOutput(text): window.outbox.setText(text) window.fancyOutbox.setText(bbcode.render_html(text)) dataFiles.reloadFiles()
def test_init_stack(self): 'Test that a new stack is created' undo._stack = None stack = undo.stack() assert stack is undo._stack assert isinstance(stack, undo.Stack)
def test_savepoint_clear(self): 'Check that clearing the stack resets the savepoint.' undo.stack()._undos = deque() assert undo.stack().haschanged() undo.stack().savepoint() assert not undo.stack().haschanged() undo.stack().clear() assert undo.stack().haschanged() undo.stack().savepoint() assert not undo.stack().haschanged() undo.stack().clear() assert undo.stack().haschanged()
def test_receiver(self): 'Test that setreceiver and resetreceiver behave correctly.' stack = [] undo.stack()._undos = [] undo.stack().setreceiver(stack) undo.stack().append('item') assert stack == ['item'] assert undo.stack()._undos == [] undo.stack().resetreceiver() undo.stack().append('next item') assert stack == ['item'] assert undo.stack()._undos == ['next item']
def test_redotext(self): 'undo.stack().redotext() returns a description of the redo available.' undo.stack()._redos = [self.action] assert undo.stack().redotext() == 'Redo blah'
def test_append(self): 'undo.stack().append adds actions to the undo queue.' undo.stack().append('one') assert undo.stack()._undos == deque(['one'])
def test_singleton(self): 'undo.stack() always returns the same object' assert undo.stack() is undo.stack()