当前位置: 首页>>代码示例>>Python>>正文


Python Machine.to_C方法代码示例

本文整理汇总了Python中transitions.Machine.to_C方法的典型用法代码示例。如果您正苦于以下问题:Python Machine.to_C方法的具体用法?Python Machine.to_C怎么用?Python Machine.to_C使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在transitions.Machine的用法示例。


在下文中一共展示了Machine.to_C方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_auto_transitions

# 需要导入模块: from transitions import Machine [as 别名]
# 或者: from transitions.Machine import to_C [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()
开发者ID:TheMysteriousX,项目名称:transitions,代码行数:15,代码来源:test_core.py

示例2: test_transition_definitions

# 需要导入模块: from transitions import Machine [as 别名]
# 或者: from transitions.Machine import to_C [as 别名]
 def test_transition_definitions(self):
     states = ["A", "B", "C", "D"]
     # Define with list of dictionaries
     transitions = [
         {"trigger": "walk", "source": "A", "dest": "B"},
         {"trigger": "run", "source": "B", "dest": "C"},
         {"trigger": "sprint", "source": "C", "dest": "D"},
     ]
     m = Machine(states=states, transitions=transitions, initial="A")
     m.walk()
     self.assertEquals(m.state, "B")
     # Define with list of lists
     transitions = [["walk", "A", "B"], ["run", "B", "C"], ["sprint", "C", "D"]]
     m = Machine(states=states, transitions=transitions, initial="A")
     m.to_C()
     m.sprint()
     self.assertEquals(m.state, "D")
开发者ID:khigia,项目名称:transitions,代码行数:19,代码来源:test_core.py

示例3: test_transition_definitions

# 需要导入模块: from transitions import Machine [as 别名]
# 或者: from transitions.Machine import to_C [as 别名]
 def test_transition_definitions(self):
     states = ['A', 'B', 'C', 'D']
     # Define with list of dictionaries
     transitions = [
         {'trigger': 'walk', 'source': 'A', 'dest': 'B'},
         {'trigger': 'run', 'source': 'B', 'dest': 'C'},
         {'trigger': 'sprint', 'source': 'C', 'dest': 'D'}
     ]
     m = Machine(states=states, transitions=transitions, initial='A')
     m.walk()
     self.assertEquals(m.state, 'B')
     # Define with list of lists
     transitions = [
         ['walk', 'A', 'B'],
         ['run', 'B', 'C'],
         ['sprint', 'C', 'D']
     ]
     m = Machine(states=states, transitions=transitions, initial='A')
     m.to_C()
     m.sprint()
     self.assertEquals(m.state, 'D')
开发者ID:TheMysteriousX,项目名称:transitions,代码行数:23,代码来源:test_core.py


注:本文中的transitions.Machine.to_C方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。