Skip to content

Commit c63d84f

Browse files
committed
more tests for untested code, delete some unused code
1 parent 871c907 commit c63d84f

3 files changed

Lines changed: 16 additions & 10 deletions

File tree

effect/__init__.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -201,15 +201,6 @@ def guard(f, *args, **kwargs):
201201
return (True, sys.exc_info())
202202

203203

204-
def _iter_conses(seq):
205-
"""
206-
Generate (head, tail) tuples so you can iterate in a way that feels like
207-
a typical recursive function over a linked list.
208-
"""
209-
for i in range(len(seq)):
210-
yield seq[i], seq[i + 1:]
211-
212-
213204
class NoEffectHandlerError(Exception):
214205
"""
215206
No Effect handler could be found for the given Effect-wrapped object.

effect/test_effect.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
raises, MatchesPredicateWithParams)
66

77
from . import (Effect, NoEffectHandlerError, synchronous_performer, perform,
8-
default_dispatcher, sync_perform)
8+
default_dispatcher, sync_perform, NotSynchronousError)
99
from .testing import StubIntent
1010

1111

@@ -106,6 +106,12 @@ def test_effects_returning_effects_returning_effects(self):
106106
StubIntent("foo"))))))),
107107
"foo")
108108

109+
def test_sync_perform_async_effect(self):
110+
"""If an effect is asynchronous, sync_effect raises an error."""
111+
self.assertRaises(NotSynchronousError,
112+
lambda: sync_perform(Effect(StubIntent("foo")),
113+
dispatcher=lambda i, box: None))
114+
109115

110116
class CallbackTests(TestCase):
111117
"""Tests for callbacks."""

effect/test_testing.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,15 @@ def test_fail_effect(self):
122122
ValueError('oh deary me')),
123123
raises(ValueError('oh deary me')))
124124

125+
def test_skip_callbacks(self):
126+
"""
127+
Intermediate callbacks of the wrong type are skipped.
128+
"""
129+
eff = (Effect('foo')
130+
.on_error(lambda f: 1)
131+
.on_success(lambda x: ('succeeded', x)))
132+
self.assertEqual(resolve_effect(eff, 'foo'), ('succeeded', 'foo'))
133+
125134

126135
def _raise(e):
127136
raise e

0 commit comments

Comments
 (0)