本文整理汇总了Python中pitivi.undo.undo.UndoableActionLog.is_in_transaction方法的典型用法代码示例。如果您正苦于以下问题:Python UndoableActionLog.is_in_transaction方法的具体用法?Python UndoableActionLog.is_in_transaction怎么用?Python UndoableActionLog.is_in_transaction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pitivi.undo.undo.UndoableActionLog
的用法示例。
在下文中一共展示了UndoableActionLog.is_in_transaction方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestUndoableActionLog
# 需要导入模块: from pitivi.undo.undo import UndoableActionLog [as 别名]
# 或者: from pitivi.undo.undo.UndoableActionLog import is_in_transaction [as 别名]
class TestUndoableActionLog(TestCase):
def setUp(self):
self.log = UndoableActionLog()
self._connectToUndoableActionLog(self.log)
self.signals = []
def tearDown(self):
self._disconnectFromUndoableActionLog(self.log)
def _undoActionLogSignalCb(self, log, *args):
args = list(args)
signalName = args.pop(-1)
self.signals.append((signalName, args))
def _connectToUndoableActionLog(self, log):
for signalName in ("begin", "push", "rollback", "commit", "move"):
log.connect(signalName, self._undoActionLogSignalCb, signalName)
def _disconnectFromUndoableActionLog(self, log):
self.log.disconnect_by_func(self._undoActionLogSignalCb)
def testRollbackWrongState(self):
self.assertRaises(UndoWrongStateError, self.log.rollback)
def testCommitWrongState(self):
self.assertRaises(UndoWrongStateError, self.log.commit, "")
def testPushWrongState(self):
# no error in this case
self.log.push(None)
def testUndoWrongState(self):
self.assertRaises(UndoWrongStateError, self.log.undo)
def testRedoWrongState(self):
self.assertRaises(UndoWrongStateError, self.log.redo)
def testCheckpoint(self):
self.log.begin("meh")
self.log.push(mock.Mock(spec=UndoableAction))
self.assertRaises(UndoWrongStateError, self.log.checkpoint)
self.log.rollback()
self.log.checkpoint()
self.assertNotEqual(self.log._checkpoint, None)
def testDirty(self):
self.assertFalse(self.log.dirty())
self.log.begin("meh")
self.log.push(mock.Mock(spec=UndoableAction))
self.log.commit("meh")
self.assertTrue(self.log.dirty())
self.log.checkpoint()
self.assertFalse(self.log.dirty())
self.log.undo()
self.assertTrue(self.log.dirty())
self.log.redo()
self.assertFalse(self.log.dirty())
def testCommit(self):
"""
Commit a stack.
"""
self.assertEqual(len(self.log.undo_stacks), 0)
self.assertEqual(len(self.log.redo_stacks), 0)
self.log.begin("meh")
self.assertEqual(len(self.signals), 1)
name, (stack,) = self.signals[0]
self.assertEqual(name, "begin")
self.assertTrue(self.log.is_in_transaction())
self.assertEqual(self.log.undo_stacks, [])
self.log.push(mock.Mock(spec=UndoableAction))
self.log.commit("meh")
self.assertEqual(len(self.signals), 3)
name, (stack, action) = self.signals[1]
self.assertEqual(name, "push")
name, (stack,) = self.signals[2]
self.assertEqual(name, "commit")
self.assertFalse(self.log.is_in_transaction())
self.assertEqual(len(self.log.undo_stacks), 1)
self.assertEqual(len(self.log.redo_stacks), 0)
def test_commit_proper(self):
self.log.begin("meh")
self.assertRaises(UndoWrongStateError, self.log.commit, "notmeh")
def testNestedCommit(self):
"""
Do two nested commits.
"""
self.assertEqual(len(self.log.undo_stacks), 0)
self.assertEqual(len(self.log.redo_stacks), 0)
self.log.begin("meh")
self.assertEqual(len(self.signals), 1)
name, (stack,) = self.signals[0]
self.assertEqual(name, "begin")
self.assertTrue(self.log.is_in_transaction())
self.assertEqual(len(self.log.undo_stacks), 0)
#.........这里部分代码省略.........