Skip to content

Commit df7c134

Browse files
committed
get rid of IntentMismatchError -- if you want that behavior, just don't have any other dispatchers
1 parent 0f76075 commit df7c134

2 files changed

Lines changed: 2 additions & 20 deletions

File tree

effect/test_testing.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
ESFunc,
1919
EQDispatcher,
2020
EQFDispatcher,
21-
IntentMismatchError,
2221
SequenceDispatcher,
2322
fail_effect,
2423
resolve_effect,
@@ -285,13 +284,10 @@ class SequenceDispatcherTests(TestCase):
285284

286285
def test_mismatch(self):
287286
"""
288-
When an intent isn't expected, a :obj:`IntentMismatchError` is raised.
287+
When an intent isn't expected, a :obj:`None` is returned.
289288
"""
290289
d = SequenceDispatcher([('foo', lambda i: 1 / 0)])
291-
e = self.assertRaises(IntentMismatchError,
292-
lambda: sync_perform(d, Effect('hello')))
293-
self.assertEqual(e.expected_intent, 'foo')
294-
self.assertEqual(e.got_intent, 'hello')
290+
self.assertEqual(d('hello'), None)
295291

296292
def test_success(self):
297293
"""

effect/testing.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -245,14 +245,6 @@ def __call__(self, intent):
245245
return sync_performer(lambda d, i: v(i))
246246

247247

248-
class IntentMismatchError(Exception):
249-
def __init__(self, expected_intent, got_intent):
250-
self.expected_intent = expected_intent
251-
self.got_intent = got_intent
252-
super(IntentMismatchError, self).__init__(
253-
'Expected intent %r, got %r' % (expected_intent, got_intent))
254-
255-
256248
class SequenceDispatcher(object):
257249
"""
258250
A dispatcher which steps through a sequence of (intent, func) tuples and
@@ -266,10 +258,6 @@ class SequenceDispatcher(object):
266258
(MyIntent('a'), lambda i: 'my-intent-result'),
267259
(OtherIntent('b'), lambda i: 'other-intent-result')
268260
])
269-
270-
Unlike most dispatchers, this one raises an exception
271-
(:obj:`IntentMismatchError`) when an intent is not found, in the order
272-
expected.
273261
"""
274262
def __init__(self, sequence):
275263
""":param list sequence: Sequence of (intent, fn)."""
@@ -280,5 +268,3 @@ def __call__(self, intent):
280268
if intent == exp_intent:
281269
self.sequence = self.sequence[1:]
282270
return sync_performer(lambda d, i: func(i))
283-
else:
284-
raise IntentMismatchError(exp_intent, intent)

0 commit comments

Comments
 (0)