Skip to content

Commit 6e0ea18

Browse files
committed
allow **kwargs in @sync_performer wrapped functions
Fixes #68
1 parent a0657e6 commit 6e0ea18

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

effect/_sync.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,11 @@ def perform_foo(dispatcher, foo):
6565
return do_side_effect(foo)
6666
"""
6767
@wraps(f)
68-
def sync_wrapper(*args):
68+
def sync_wrapper(*args, **kwargs):
6969
box = args[-1]
7070
pass_args = args[:-1]
7171
try:
72-
box.succeed(f(*pass_args))
72+
box.succeed(f(*pass_args, **kwargs))
7373
except:
7474
box.fail(sys.exc_info())
7575
return sync_wrapper

effect/test_sync.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,13 @@ def original(something, dispatcher, intent):
114114
original.attr = 1
115115
wrapped = sync_performer(new_func)
116116
self.assertEqual(wrapped.__name__, 'sync_wrapper')
117+
118+
def test_kwargs(self):
119+
"""Additional kwargs are passed through."""
120+
@sync_performer
121+
def p(dispatcher, intent, extra):
122+
return extra
123+
124+
dispatcher = lambda _: partial(p, extra='extra val')
125+
result = sync_perform(dispatcher, Effect('foo'))
126+
self.assertEqual(result, 'extra val')

0 commit comments

Comments
 (0)