Skip to content

Commit a9db4d5

Browse files
committed
don't silence TypeErrors in resolve_stubs.
1 parent c591e36 commit a9db4d5

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

effect/test_testing.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,17 @@ def test_non_test_intent(self):
158158
self.assertIs(result_eff.intent, bare_effect.intent)
159159
self.assertEqual(result_eff.callbacks, [])
160160

161+
def test_type_error(self):
162+
"""
163+
TypeErrors in callbacks (or otherwise performed intents) are propagated
164+
resolve_stubs.
165+
166+
(This only exists because the initial implementation was done stupidly,
167+
and had to be fixed.)
168+
"""
169+
eff = Constant("foo").on(success=lambda r: None["foo"])
170+
self.assertRaises(TypeError, resolve_stubs, eff)
171+
161172

162173
def _raise(e):
163174
raise e

effect/testing.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,9 @@ def resolve_stubs(effect):
100100
raise TypeError("effect must be Effect: %r" % (effect,))
101101

102102
while type(effect) is Effect:
103-
try:
103+
if type(effect.intent) is StubIntent:
104104
effect = resolve_stub(effect)
105-
except TypeError:
105+
else:
106106
break
107+
107108
return effect

0 commit comments

Comments
 (0)