forked from pool/python-pook
39 lines
1.2 KiB
Diff
39 lines
1.2 KiB
Diff
|
Index: pook-1.1.0/pook/activate_async.py
|
||
|
===================================================================
|
||
|
--- pook-1.1.0.orig/pook/activate_async.py
|
||
|
+++ pook-1.1.0/pook/activate_async.py
|
||
|
@@ -1,5 +1,5 @@
|
||
|
import functools
|
||
|
-from asyncio import iscoroutinefunction, coroutine
|
||
|
+from asyncio import iscoroutinefunction
|
||
|
|
||
|
|
||
|
def activate_async(fn, _engine):
|
||
|
@@ -13,13 +13,13 @@ def activate_async(fn, _engine):
|
||
|
Returns:
|
||
|
function: decorator wrapper function.
|
||
|
"""
|
||
|
- @coroutine
|
||
|
@functools.wraps(fn)
|
||
|
- def wrapper(*args, **kw):
|
||
|
+ async def wrapper(*args, **kw):
|
||
|
_engine.activate()
|
||
|
try:
|
||
|
if iscoroutinefunction(fn):
|
||
|
- yield from fn(*args, **kw) # noqa
|
||
|
+ async for v in fn(*args, **kw):
|
||
|
+ yield v
|
||
|
else:
|
||
|
fn(*args, **kw)
|
||
|
finally:
|
||
|
Index: pook-1.1.0/tests/unit/mock_test.py
|
||
|
===================================================================
|
||
|
--- pook-1.1.0.orig/tests/unit/mock_test.py
|
||
|
+++ pook-1.1.0/tests/unit/mock_test.py
|
||
|
@@ -19,4 +19,4 @@ def test_mock_url(mock):
|
||
|
|
||
|
|
||
|
def test_new_response(mock):
|
||
|
- assert(mock.reply() != mock.reply(new_response=True, json={}))
|
||
|
+ assert mock.reply() != mock.reply(new_response=True, json={})
|