Skip to content

Commit 60c8b4c

Browse files
committed
Address @cyli's two points -- a test for ordering, and documentation of when None is returned.
1 parent 28c8544 commit 60c8b4c

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

effect/test_testing.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ class SequenceDispatcherTests(TestCase):
284284

285285
def test_mismatch(self):
286286
"""
287-
When an intent isn't expected, a :obj:`None` is returned.
287+
When an intent isn't expected, a None is returned.
288288
"""
289289
d = SequenceDispatcher([('foo', lambda i: 1 / 0)])
290290
self.assertEqual(d('hello'), None)
@@ -307,3 +307,11 @@ def test_ran_out(self):
307307
"""When there are no more items left, None is returned."""
308308
d = SequenceDispatcher([])
309309
self.assertEqual(d('foo'), None)
310+
311+
def test_out_of_order(self):
312+
"""Order of items in the sequence matters."""
313+
d = SequenceDispatcher([
314+
('bar', lambda i: ('performbar', i)),
315+
('foo', lambda i: ('performfoo', i)),
316+
])
317+
self.assertEqual(d('foo'), None)

effect/testing.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,10 @@ class SequenceDispatcher(object):
258258
(MyIntent('a'), lambda i: 'my-intent-result'),
259259
(OtherIntent('b'), lambda i: 'other-intent-result')
260260
])
261+
262+
:obj:`None` is returned if the next intent in the sequence is not equal to
263+
the intent being performed, or if there are no more items left in the
264+
sequence.
261265
"""
262266
def __init__(self, sequence):
263267
""":param list sequence: Sequence of (intent, fn)."""

0 commit comments

Comments
 (0)