本文整理汇总了Python中transitions.Machine.to_A方法的典型用法代码示例。如果您正苦于以下问题:Python Machine.to_A方法的具体用法?Python Machine.to_A怎么用?Python Machine.to_A使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类transitions.Machine
的用法示例。
在下文中一共展示了Machine.to_A方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_auto_transitions
# 需要导入模块: from transitions import Machine [as 别名]
# 或者: from transitions.Machine import to_A [as 别名]
def test_auto_transitions(self):
states = ['A', {'name': 'B'}, State(name='C')]
m = Machine(None, states, initial='A', auto_transitions=True)
m.to_B()
self.assertEquals(m.state, 'B')
m.to_C()
self.assertEquals(m.state, 'C')
m.to_A()
self.assertEquals(m.state, 'A')
# Should fail if auto transitions is off...
m = Machine(None, states, initial='A', auto_transitions=False)
with self.assertRaises(AttributeError):
m.to_C()
示例2: test_enter_exit_callbacks_callables
# 需要导入模块: from transitions import Machine [as 别名]
# 或者: from transitions.Machine import to_A [as 别名]
def test_enter_exit_callbacks_callables(self):
exit_mock = MagicMock()
enter_mock = MagicMock()
# on_enter doesn't fire on initialisation so need a dummy start state
m = Machine(None, states=['dummy', 'A', 'B'], send_event=True,
initial='dummy', auto_transitions=True)
m.on_exit_A(exit_mock)
m.on_enter_B(enter_mock)
m.to_A()
m.to_B()
self.assertTrue(exit_mock.called)
self.assertTrue(enter_mock.called)