diff options
author | Yury Selivanov <yselivanov@sprymix.com> | 2015-08-14 15:32:37 -0400 |
---|---|---|
committer | Yury Selivanov <yselivanov@sprymix.com> | 2015-08-14 15:32:37 -0400 |
commit | bb78adeece6cb87c0e20eec36f65cad7c23f27af (patch) | |
tree | ff52a350a2dba148b026288a7aec3a6189ccac8f /Lib/test | |
parent | 7c97a05618733b93f0a6e80ad5b672c2f966f448 (diff) | |
parent | 233983380d1868126918fd86252d6328b0f0ad50 (diff) | |
download | cpython-git-bb78adeece6cb87c0e20eec36f65cad7c23f27af.tar.gz |
Merge 3.4 (Issue #24867)
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_asyncio/test_pep492.py | 17 | ||||
-rw-r--r-- | Lib/test/test_asyncio/test_tasks.py | 32 |
2 files changed, 49 insertions, 0 deletions
diff --git a/Lib/test/test_asyncio/test_pep492.py b/Lib/test/test_asyncio/test_pep492.py index b702efcdfd..41e1b8a9e0 100644 --- a/Lib/test/test_asyncio/test_pep492.py +++ b/Lib/test/test_asyncio/test_pep492.py @@ -186,6 +186,23 @@ class CoroutineTests(BaseTest): data = self.loop.run_until_complete(coro()) self.assertEqual(data, 'spam') + def test_task_print_stack(self): + T = None + + async def foo(): + f = T.get_stack(limit=1) + try: + self.assertEqual(f[0].f_code.co_name, 'foo') + finally: + f = None + + async def runner(): + nonlocal T + T = asyncio.ensure_future(foo(), loop=self.loop) + await T + + self.loop.run_until_complete(runner()) + if __name__ == '__main__': unittest.main() diff --git a/Lib/test/test_asyncio/test_tasks.py b/Lib/test/test_asyncio/test_tasks.py index 251192acee..0426787310 100644 --- a/Lib/test/test_asyncio/test_tasks.py +++ b/Lib/test/test_asyncio/test_tasks.py @@ -2,6 +2,7 @@ import contextlib import functools +import io import os import re import sys @@ -162,6 +163,37 @@ class TaskTests(test_utils.TestCase): 'function is deprecated, use ensure_'): self.assertIs(f, asyncio.async(f)) + def test_get_stack(self): + T = None + + @asyncio.coroutine + def foo(): + yield from bar() + + @asyncio.coroutine + def bar(): + # 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 = io.StringIO() + T.print_stack(limit=1, file=file) + file.seek(0) + tb = file.read() + self.assertRegex(tb, r'foo\(\) running') + + @asyncio.coroutine + def runner(): + nonlocal T + T = asyncio.ensure_future(foo(), loop=self.loop) + yield from T + + self.loop.run_until_complete(runner()) + def test_task_repr(self): self.loop.set_debug(False) |