本文整理汇总了Python中transitions.Machine.go方法的典型用法代码示例。如果您正苦于以下问题:Python Machine.go方法的具体用法?Python Machine.go怎么用?Python Machine.go使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类transitions.Machine
的用法示例。
在下文中一共展示了Machine.go方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_machine_prepare
# 需要导入模块: from transitions import Machine [as 别名]
# 或者: from transitions.Machine import go [as 别名]
def test_machine_prepare(self):
global_mock = MagicMock()
local_mock = MagicMock()
def global_callback():
global_mock()
def local_callback():
local_mock()
def always_fails():
return False
transitions = [
{'trigger': 'go', 'source': 'A', 'dest': 'B', 'conditions': always_fails, 'prepare': local_callback},
{'trigger': 'go', 'source': 'A', 'dest': 'B', 'conditions': always_fails, 'prepare': local_callback},
{'trigger': 'go', 'source': 'A', 'dest': 'B', 'conditions': always_fails, 'prepare': local_callback},
{'trigger': 'go', 'source': 'A', 'dest': 'B', 'conditions': always_fails, 'prepare': local_callback},
{'trigger': 'go', 'source': 'A', 'dest': 'B', 'prepare': local_callback},
]
m = Machine(states=['A', 'B'], transitions=transitions,
prepare_event=global_callback, initial='A')
m.go()
self.assertEqual(global_mock.call_count, 1)
self.assertEqual(local_mock.call_count, len(transitions))