Skip to content

Commit 27cc67e

Browse files
committed
Consider transitions.dest is None for Machine._can_trigger
This fixes #594
1 parent 0eb4712 commit 27cc67e

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

Changelog.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 0.9.1 ()
4+
5+
- Bug #594: Fix may_<trigger> always returning false for internal transitions (thanks @a-schade)
6+
37
## 0.9.0 (September 2022)
48

59
Release 0.9.0 is a major release and contains improvements to ease development, adds some new features and removes the legacy hierarchical machine:

tests/test_core.py

+3
Original file line numberDiff line numberDiff line change
@@ -1229,12 +1229,15 @@ def test_may_transition(self):
12291229
m = Machine(model=d, states=states, initial='A', auto_transitions=False)
12301230
m.add_transition('walk', 'A', 'B')
12311231
m.add_transition('stop', 'B', 'C')
1232+
m.add_transition('wait', 'B', None)
12321233
assert d.may_walk()
12331234
assert not d.may_stop()
1235+
assert not d.may_wait()
12341236

12351237
d.walk()
12361238
assert not d.may_walk()
12371239
assert d.may_stop()
1240+
assert d.may_wait()
12381241

12391242
def test_may_transition_for_autogenerated_triggers(self):
12401243
states = ['A', 'B', 'C']

transitions/core.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -884,7 +884,7 @@ def _can_trigger(self, model, trigger, *args, **kwargs):
884884
continue
885885
for transition in self.events[trigger_name].transitions[state]:
886886
try:
887-
_ = self.get_state(transition.dest)
887+
_ = transition.source if transition.dest is None else self.get_state(transition.dest)
888888
except ValueError:
889889
continue
890890

0 commit comments

Comments
 (0)