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


Python Machine.send_event方法代码示例

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


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

示例1: test_send_event_data_conditions

# 需要导入模块: from transitions import Machine [as 别名]
# 或者: from transitions.Machine import send_event [as 别名]
 def test_send_event_data_conditions(self):
     states = ["A", "B", "C", "D"]
     s = Stuff()
     # First pass positional and keyword args directly to the condition
     m = Machine(model=s, states=states, initial="A", send_event=False)
     m.add_transition(trigger="advance", source="A", dest="B", conditions="this_fails_by_default")
     s.advance(boolean=True)
     self.assertEquals(s.state, "B")
     # Now wrap arguments in an EventData instance
     m.send_event = True
     m.add_transition(trigger="advance", source="B", dest="C", conditions="extract_boolean")
     s.advance(boolean=False)
     self.assertEquals(s.state, "B")
开发者ID:khigia,项目名称:transitions,代码行数:15,代码来源:test_core.py

示例2: test_send_event_data

# 需要导入模块: from transitions import Machine [as 别名]
# 或者: from transitions.Machine import send_event [as 别名]
 def test_send_event_data(self):
     states = ['A', 'B', 'C', 'D']
     s = Stuff()
     # First pass positional and keyword args directly to the callback
     m = Machine(model=s, states=states, initial='A', send_event=False)
     m.add_transition(
         trigger='advance', source='A', dest='B', before='set_message')
     s.advance(message='Hallo. My name is Inigo Montoya.')
     self.assertTrue(s.message.startswith('Hallo.'))
     # Now wrap arguments in an EventData instance
     m.send_event = True
     m.add_transition(
         trigger='advance', source='B', dest='C', before='extract_message')
     s.advance(message='You killed my father. Prepare to die.')
     self.assertTrue(s.message.startswith('You'))
开发者ID:barseghyanartur,项目名称:transitions,代码行数:17,代码来源:test_transitions.py

示例3: test_send_event_data_conditions

# 需要导入模块: from transitions import Machine [as 别名]
# 或者: from transitions.Machine import send_event [as 别名]
 def test_send_event_data_conditions(self):
     states = ['A', 'B', 'C', 'D']
     s = Stuff()
     # First pass positional and keyword args directly to the condition
     m = Machine(model=s, states=states, initial='A', send_event=False)
     m.add_transition(
         trigger='advance', source='A', dest='B', conditions='this_fails_by_default')
     s.advance(boolean=True)
     self.assertEquals(s.state, 'B')
     # Now wrap arguments in an EventData instance
     m.send_event = True
     m.add_transition(
         trigger='advance', source='B', dest='C', conditions='extract_boolean')
     s.advance(boolean=False)
     self.assertEquals(s.state, 'B')
开发者ID:acjc,项目名称:transitions,代码行数:17,代码来源:test_transitions.py

示例4: test_send_event_data_callbacks

# 需要导入模块: from transitions import Machine [as 别名]
# 或者: from transitions.Machine import send_event [as 别名]
 def test_send_event_data_callbacks(self):
     states = ["A", "B", "C", "D", "E"]
     s = Stuff()
     # First pass positional and keyword args directly to the callback
     m = Machine(model=s, states=states, initial="A", send_event=False, auto_transitions=True)
     m.add_transition(trigger="advance", source="A", dest="B", before="set_message")
     s.advance(message="Hallo. My name is Inigo Montoya.")
     self.assertTrue(s.message.startswith("Hallo."))
     # Make sure callbacks handle arguments properly
     s.to_E("Optional message")
     self.assertEquals(s.message, "Optional message")
     s.to_B()
     # Now wrap arguments in an EventData instance
     m.send_event = True
     m.add_transition(trigger="advance", source="B", dest="C", before="extract_message")
     s.advance(message="You killed my father. Prepare to die.")
     self.assertTrue(s.message.startswith("You"))
开发者ID:khigia,项目名称:transitions,代码行数:19,代码来源:test_core.py


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