mirror of
https://github.com/python/cpython.git
synced 2025-08-03 08:34:29 +00:00
asyncio: repr(Task) now also contains the line number even if the coroutine is
done: use the first line number of the code object instead of the current line number of the generator frame. The name of the coroutine is not enough because many coroutines may have the same name. It's a common case in asyncio tests for example.
This commit is contained in:
parent
14199f9392
commit
df29c4a83d
2 changed files with 8 additions and 4 deletions
|
@ -148,12 +148,14 @@ class TaskTests(test_utils.TestCase):
|
|||
self.assertRaises(asyncio.CancelledError,
|
||||
self.loop.run_until_complete, t)
|
||||
self.assertEqual(repr(t),
|
||||
'Task(<notmuch done at %s>)<CANCELLED>' % filename)
|
||||
'Task(<notmuch done at %s:%s>)<CANCELLED>'
|
||||
% (filename, lineno))
|
||||
|
||||
t = asyncio.Task(notmuch(), loop=self.loop)
|
||||
self.loop.run_until_complete(t)
|
||||
self.assertEqual(repr(t),
|
||||
"Task(<notmuch done at %s>)<result='abc'>" % filename)
|
||||
"Task(<notmuch done at %s:%s>)<result='abc'>"
|
||||
% (filename, lineno))
|
||||
|
||||
def test_task_repr_custom(self):
|
||||
@asyncio.coroutine
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue