summaryrefslogtreecommitdiff
path: root/src/tests/test.py
diff options
context:
space:
mode:
authorMichele Simionato <michele.simionato@gmail.com>2017-07-23 17:18:05 +0200
committerMichele Simionato <michele.simionato@gmail.com>2017-07-23 17:18:05 +0200
commit15d908b3ce3db5607c75f7dff052b1541f73f534 (patch)
tree4532907d559ca1bf9bab22e924d77594236eebc9 /src/tests/test.py
parentbdc76f0c7bcd011324b6001acc166c9e90593b00 (diff)
downloadpython-decorator-git-15d908b3ce3db5607c75f7dff052b1541f73f534.tar.gz
Updated the docs
Diffstat (limited to 'src/tests/test.py')
-rw-r--r--src/tests/test.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/tests/test.py b/src/tests/test.py
index fdc3727..7eb8391 100644
--- a/src/tests/test.py
+++ b/src/tests/test.py
@@ -30,15 +30,25 @@ if sys.version >= '3.5':
async def before_after(coro, *args, **kwargs):
return "<before>" + (await coro(*args, **kwargs)) + "<after>"
+@decorator
+def coro_to_func(coro, *args, **kw):
+ return get_event_loop().run_until_complete(coro(*args, **kw))
class CoroutineTestCase(unittest.TestCase):
- def test(self):
+ def test_before_after(self):
@before_after
async def coro(x):
return x
self.assertTrue(inspect.iscoroutinefunction(coro))
out = get_event_loop().run_until_complete(coro('x'))
self.assertEqual(out, '<before>x<after>')
+
+ def test_coro_to_func(self):
+ @coro_to_func
+ async def coro(x):
+ return x
+ self.assertFalse(inspect.iscoroutinefunction(coro))
+ self.assertEqual(coro('x'), 'x')
''')