本文整理汇总了Python中pitivi.undo.undo.UndoableActionLog.started方法的典型用法代码示例。如果您正苦于以下问题:Python UndoableActionLog.started方法的具体用法?Python UndoableActionLog.started怎么用?Python UndoableActionLog.started使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pitivi.undo.undo.UndoableActionLog
的用法示例。
在下文中一共展示了UndoableActionLog.started方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestUndoableActionLog
# 需要导入模块: from pitivi.undo.undo import UndoableActionLog [as 别名]
# 或者: from pitivi.undo.undo.UndoableActionLog import started [as 别名]
#.........这里部分代码省略.........
self.assertEqual(len(self.log.undo_stacks), 0)
self.assertEqual(len(self.log.redo_stacks), 0)
self.log.begin("nested")
self.assertEqual(len(self.signals), 2)
name, (stack,) = self.signals[1]
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("nested")
self.assertEqual(len(self.signals), 4)
name, (stack, action) = self.signals[2]
self.assertEqual(name, "push")
name, (stack,) = self.signals[3]
self.assertEqual(name, "commit")
self.assertTrue(self.log.is_in_transaction())
self.assertEqual(len(self.log.undo_stacks), 0)
self.assertEqual(len(self.log.redo_stacks), 0)
self.assertEqual(self.log.undo_stacks, [])
self.log.commit("meh")
self.assertEqual(len(self.signals), 5)
name, (stack,) = self.signals[4]
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_finalizing_action(self):
action1 = mock.Mock()
action2 = mock.Mock()
with self.log.started("one", finalizing_action=action1):
self.log.push(mock.Mock(spec=UndoableAction))
with self.log.started("two", finalizing_action=action2):
self.log.push(mock.Mock(spec=UndoableAction))
action1.do.assert_called_once_with()
# For now, we call the finalizing action only for the top stack.
action2.do.assert_not_called()
def testRollback(self):
"""
Test a rollback.
"""
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.log.rollback()
self.assertEqual(len(self.signals), 2)
name, (stack,) = self.signals[1]
self.assertEqual(name, "rollback")
self.assertFalse(self.log.is_in_transaction())
self.assertEqual(len(self.log.undo_stacks), 0)
self.assertEqual(len(self.log.redo_stacks), 0)
def testNestedRollback(self):
"""
Test two nested rollbacks.
"""
self.assertEqual(len(self.log.undo_stacks), 0)