diff options
Diffstat (limited to 'tests/test_tasks.py')
-rw-r--r-- | tests/test_tasks.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/test_tasks.py b/tests/test_tasks.py index afa1190..6576ddb 100644 --- a/tests/test_tasks.py +++ b/tests/test_tasks.py @@ -2,8 +2,10 @@ import contextlib import functools +import io import os import re +import six import sys import types import weakref @@ -157,6 +159,37 @@ class TaskTests(test_utils.TestCase): 'function is deprecated, use ensure_'): self.assertIs(f, asyncio.async(f)) + def test_get_stack(self): + non_local = {'T': None} + + @asyncio.coroutine + def foo(): + yield From(bar()) + + @asyncio.coroutine + def bar(): + T = non_local['T'] + # test get_stack() + f = T.get_stack(limit=1) + try: + self.assertEqual(f[0].f_code.co_name, 'foo') + finally: + f = None + + # test print_stack() + file = six.StringIO() + T.print_stack(limit=1, file=file) + file.seek(0) + tb = file.read() + self.assertRegex(tb, r'foo\(\) running') + + @asyncio.coroutine + def runner(): + non_local['T'] = asyncio.ensure_future(foo(), loop=self.loop) + yield From(non_local['T']) + + self.loop.run_until_complete(runner()) + def test_task_repr(self): self.loop.set_debug(False) |