File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 )
Original file line number Diff line number Diff 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)."""
You can’t perform that action at this time.
0 commit comments