本文整理汇总了Python中transitions.Machine.sprint方法的典型用法代码示例。如果您正苦于以下问题:Python Machine.sprint方法的具体用法?Python Machine.sprint怎么用?Python Machine.sprint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类transitions.Machine
的用法示例。
在下文中一共展示了Machine.sprint方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_transition_definitions
# 需要导入模块: from transitions import Machine [as 别名]
# 或者: from transitions.Machine import sprint [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")
示例2: test_transition_definitions
# 需要导入模块: from transitions import Machine [as 别名]
# 或者: from transitions.Machine import sprint [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')