本文整理汇总了Python中transitions.Machine.to_D方法的典型用法代码示例。如果您正苦于以下问题:Python Machine.to_D方法的具体用法?Python Machine.to_D怎么用?Python Machine.to_D使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类transitions.Machine
的用法示例。
在下文中一共展示了Machine.to_D方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_ignore_invalid_triggers
# 需要导入模块: from transitions import Machine [as 别名]
# 或者: from transitions.Machine import to_D [as 别名]
def test_ignore_invalid_triggers(self):
a_state = State('A')
transitions = [['a_to_b', 'A', 'B']]
# Exception is triggered by default
b_state = State('B')
m1 = Machine(None, states=[a_state, b_state], transitions=transitions,
initial='B')
with self.assertRaises(MachineError):
m1.a_to_b()
# Exception is suppressed, so this passes
b_state = State('B', ignore_invalid_triggers=True)
m2 = Machine(None, states=[a_state, b_state], transitions=transitions,
initial='B')
m2.a_to_b()
# Set for some states but not others
new_states = ['C', 'D']
m1.add_states(new_states, ignore_invalid_triggers=True)
m1.to_D()
m1.a_to_b() # passes because exception suppressed for D
m1.to_B()
with self.assertRaises(MachineError):
m1.a_to_b()
# Set at machine level
m3 = Machine(None, states=[a_state, b_state], transitions=transitions,
initial='B', ignore_invalid_triggers=True)
m3.a_to_b()