本文整理汇总了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")
示例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'))
示例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')
示例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"))