本文整理汇总了Python中fysom.Fysom.eat方法的典型用法代码示例。如果您正苦于以下问题:Python Fysom.eat方法的具体用法?Python Fysom.eat怎么用?Python Fysom.eat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fysom.Fysom
的用法示例。
在下文中一共展示了Fysom.eat方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_if_src_not_specified_then_is_wildcard
# 需要导入模块: from fysom import Fysom [as 别名]
# 或者: from fysom.Fysom import eat [as 别名]
def test_if_src_not_specified_then_is_wildcard(self):
fsm = Fysom({
'initial': 'hungry',
'events': [
{'name': 'eat', 'src': 'hungry', 'dst': 'satisfied'},
{'name': 'eat', 'src': 'satisfied', 'dst': 'full'},
{'name': 'eat', 'src': 'full', 'dst': 'sick'},
{'name': 'rest', 'dst': 'hungry'}
]
})
fsm.eat()
self.assertEqual(fsm.current, 'satisfied')
fsm.rest()
self.assertEqual(fsm.current, 'hungry')
fsm.eat()
fsm.eat()
self.assertEqual(fsm.current, 'full')
fsm.rest()
self.assertEqual(fsm.current, 'hungry')
示例2: Fysom
# 需要导入模块: from fysom import Fysom [as 别名]
# 或者: from fysom.Fysom import eat [as 别名]
fsm = Fysom({
'initial': 'hungry',
'events': [
{'name': 'eat', 'src': 'hungry', 'dst': 'satisfied'},
{'name': 'eat', 'src': 'satisfied', 'dst': 'full'},
{'name': 'eat', 'src': 'full', 'dst': 'sick'},
{'name': 'rest', 'src': ['hungry', 'satisfied', 'full', 'sick'],
'dst': 'hungry'}
],
'callbacks': {
'oneat': oneat
}
})
#
# print(fsm.current)
fsm.eat(keyparameter=1)
print(fsm.current)
# kwargs testcase
def foo(**kwargs):
print("foo:kwargs")
print kwargs
foo(key1=1,key2="2")
# setattr for new function inject testcase
print("setattr for new function inject testcase")
class foo_c:
def __init__(self):
setattr(self,"inject_fun",self.build_fun())
def build_fun(self):
def foo(**kwargs):
print("into foo for build_fun")
print kwargs
示例3: test_eat_should_transition_to_full_when_satisfied
# 需要导入模块: from fysom import Fysom [as 别名]
# 或者: from fysom.Fysom import eat [as 别名]
def test_eat_should_transition_to_full_when_satisfied(self):
fsm = Fysom(self._get_descr('satisfied'))
fsm.eat()
self.assertEqual(fsm.current, 'full')
示例4: test_eat_should_transition_to_sick_when_full
# 需要导入模块: from fysom import Fysom [as 别名]
# 或者: from fysom.Fysom import eat [as 别名]
def test_eat_should_transition_to_sick_when_full(self):
fsm = Fysom(self._get_descr('full'))
fsm.eat()
self.assertEqual(fsm.current, 'sick')
示例5: test_eat_should_transition_to_satisfied_when_hungry
# 需要导入模块: from fysom import Fysom [as 别名]
# 或者: from fysom.Fysom import eat [as 别名]
def test_eat_should_transition_to_satisfied_when_hungry(self):
fsm = Fysom(self._get_descr('hungry'))
fsm.eat()
self.assertEqual(fsm.current, 'satisfied')