diff options
| author | Larry Hastings <larry@hastings.org> | 2015-08-24 23:53:45 (GMT) |
|---|---|---|
| committer | Larry Hastings <larry@hastings.org> | 2015-08-24 23:53:45 (GMT) |
| commit | 7250d02b738692fb76a47d75691cca6ba1561040 (patch) | |
| tree | 057f93baf56d258d3161fe9686683f94195b1eff /Lib/test/test_asyncio/test_tasks.py | |
| parent | 90f5bca3b6e80add7bfaba4d1dce5df1affba951 (diff) | |
| parent | 7ca6c55a4e2655dc0e5d780c3cc2ed7234edd72f (diff) | |
| download | cpython-7250d02b738692fb76a47d75691cca6ba1561040.zip cpython-7250d02b738692fb76a47d75691cca6ba1561040.tar.gz cpython-7250d02b738692fb76a47d75691cca6ba1561040.tar.bz2 | |
Merged in 1st1/cpython350 (pull request #5)
Issue #24867: Fix asyncio.Task.get_stack() for 'async def' coroutines
Diffstat (limited to 'Lib/test/test_asyncio/test_tasks.py')
| -rw-r--r-- | Lib/test/test_asyncio/test_tasks.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/Lib/test/test_asyncio/test_tasks.py b/Lib/test/test_asyncio/test_tasks.py index 251192a..0426787 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) |
