本文整理汇总了Python中fysom.Fysom.panic方法的典型用法代码示例。如果您正苦于以下问题:Python Fysom.panic方法的具体用法?Python Fysom.panic怎么用?Python Fysom.panic使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fysom.Fysom
的用法示例。
在下文中一共展示了Fysom.panic方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_init_kwargs_only
# 需要导入模块: from fysom import Fysom [as 别名]
# 或者: from fysom.Fysom import panic [as 别名]
def test_init_kwargs_only(self):
fsm = Fysom(initial='green',
events=[('panic', 'green', 'red'),
('calm', 'red', 'green')])
self.assertEqual(fsm.current, "green")
fsm.panic()
self.assertEqual(fsm.current, "red")
fsm.calm()
self.assertEqual(fsm.current, "green")
示例2: test_never_finished_if_final_is_unspecified
# 需要导入模块: from fysom import Fysom [as 别名]
# 或者: from fysom.Fysom import panic [as 别名]
def test_never_finished_if_final_is_unspecified(self):
fsm = Fysom({
'initial': 'green',
'events': [
{'name': 'warn', 'src': 'green', 'dst': 'yellow'},
{'name': 'panic', 'src': 'yellow', 'dst': 'red'},
{'name': 'calm', 'src': 'red', 'dst': 'yellow'},
{'name': 'clear', 'src': 'yellow', 'dst': 'green'}
]
})
self.assertFalse(fsm.is_finished())
fsm.warn()
self.assertFalse(fsm.is_finished())
fsm.panic()
self.assertFalse(fsm.is_finished())
示例3: test_it_should_indicate_whether_fsm_in_finished_state
# 需要导入模块: from fysom import Fysom [as 别名]
# 或者: from fysom.Fysom import panic [as 别名]
def test_it_should_indicate_whether_fsm_in_finished_state(self):
fsm = Fysom({
'initial': 'green',
'final': 'red',
'events': [
{'name': 'warn', 'src': 'green', 'dst': 'yellow'},
{'name': 'panic', 'src': 'yellow', 'dst': 'red'},
{'name': 'calm', 'src': 'red', 'dst': 'yellow'},
{'name': 'clear', 'src': 'yellow', 'dst': 'green'}
]
})
self.assertFalse(fsm.is_finished())
fsm.warn()
self.assertFalse(fsm.is_finished())
fsm.panic()
self.assertTrue(fsm.is_finished())
示例4: test_tuples_as_trasition_spec
# 需要导入模块: from fysom import Fysom [as 别名]
# 或者: from fysom.Fysom import panic [as 别名]
def test_tuples_as_trasition_spec(self):
fsm = Fysom({
'initial': 'green',
'events': [ # freely mix dicts and tuples
{'name': 'warn', 'src': 'green', 'dst': 'yellow'},
('panic', 'yellow', 'red'),
('calm', 'red', 'yellow'),
{'name': 'clear', 'src': 'yellow', 'dst': 'green'}
]
})
fsm.warn()
fsm.panic()
self.assertEqual(fsm.current, 'red')
fsm.calm()
fsm.clear()
self.assertEqual(fsm.current, 'green')
示例5: MyTestObject
# 需要导入模块: from fysom import Fysom [as 别名]
# 或者: from fysom.Fysom import panic [as 别名]
class MyTestObject(object):
def __init__(self):
self._states = []
self._fsm = Fysom({
'initial': 'green',
'events': [
{'name': 'warn', 'src': 'green', 'dst': 'yellow'},
{'name': 'panic', 'src': 'yellow', 'dst': 'red'},
{'name': 'calm', 'src': 'red', 'dst': 'yellow'},
{'name': 'clear', 'src': 'yellow', 'dst': 'green'}
],
'callbacks': {
'ongreen': self._on_green,
'onyellow': self._on_yellow,
'onred': self._on_red
}
})
def warn(self):
self._fsm.warn()
def panic(self):
self._fsm.panic()
def calm(self):
self._fsm.calm()
def clear(self):
self._fsm.clear()
def _on_green(self, *args, **kwargs):
self._states.append('green')
def _on_yellow(self, *args, **kwargs):
self._states.append('yellow')
def _on_red(self, *args, **kwargs):
self._states.append('red')