diff --git a/taskflow/tests/unit/test_types.py b/taskflow/tests/unit/test_types.py index 395d7d9b..28b57251 100644 --- a/taskflow/tests/unit/test_types.py +++ b/taskflow/tests/unit/test_types.py @@ -304,7 +304,9 @@ class FSMTest(test.TestCase): m.process_event('fall') self.assertEqual([('down', 'beat'), ('up', 'jump'), ('down', 'fall')], enter_transitions) - self.assertEqual([('down', 'jump'), ('up', 'fall')], exit_transitions) + self.assertEqual( + [('start', 'beat'), ('down', 'jump'), ('up', 'fall')], + exit_transitions) def test_run_iter(self): up_downs = [] diff --git a/taskflow/types/fsm.py b/taskflow/types/fsm.py index 9cf94d7b..2519e840 100644 --- a/taskflow/types/fsm.py +++ b/taskflow/types/fsm.py @@ -196,7 +196,12 @@ class FSM(object): if self._states[self._start_state]['terminal']: raise excp.InvalidState("Can not start from a terminal" " state '%s'" % (self._start_state)) - self._current = _Jump(self._start_state, None, None) + # No on enter will be called, since we are priming the state machine + # and have not really transitioned from anything to get here, we will + # though allow 'on_exit' to be called on the event that causes this + # to be moved from... + self._current = _Jump(self._start_state, None, + self._states[self._start_state]['on_exit']) def run(self, event, initialize=True): """Runs the state machine, using reactions only."""