Skip to content

Commit 74d2aef

Browse files
committed
show next expected intent in the perform_sequence exception
1 parent d3ac5f8 commit 74d2aef

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

effect/testing.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ def test_code():
7474
* ``fallback``: a performer for this intent was provided by the fallback
7575
dispatcher
7676
* ``NOT FOUND``: no performer for this intent was found.
77+
* ``NEXT EXPECTED``: the next item in the sequence, if there is one. This
78+
will appear immediately after a ``NOT FOUND``.
7779
7880
:param list sequence: List of ``(intent, fn)`` tuples, where ``fn`` is a
7981
function that should accept an intent and return a result.
@@ -83,7 +85,12 @@ def test_code():
8385
used.
8486
"""
8587
def fmt_log():
86-
return '{{{\n%s\n}}}' % ('\n'.join(['%s: %s' % x for x in log]),)
88+
next_item = ''
89+
if len(sequence.sequence) > 0:
90+
next_item = '\nNEXT EXPECTED: %s' % (sequence.sequence[0][0],)
91+
return '{{{\n%s%s\n}}}' % (
92+
'\n'.join('%s: %s' % x for x in log),
93+
next_item)
8794

8895
def dispatcher(intent):
8996
p = sequence(intent)

0 commit comments

Comments
 (0)