summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_asyncio
diff options
context:
space:
mode:
authorYury Selivanov <yury@magic.io>2016-11-09 00:16:01 (GMT)
committerYury Selivanov <yury@magic.io>2016-11-09 00:16:01 (GMT)
commit6cc495e9e2db8de0b8b7d95323d3a1514844b1b4 (patch)
tree53ad200923868483dd72cee032bb1050d297870f /Lib/test/test_asyncio
parent70b72f0f96d0a78e7cb154ae64356c82d06ac901 (diff)
downloadcpython-6cc495e9e2db8de0b8b7d95323d3a1514844b1b4.zip
cpython-6cc495e9e2db8de0b8b7d95323d3a1514844b1b4.tar.gz
cpython-6cc495e9e2db8de0b8b7d95323d3a1514844b1b4.tar.bz2
asyncio: Fix _format_coroutine for coroutine-like objects w/o __name__
Some built-in coroutine-like objects might not have __name__ or __qualname__. A good example of such are 'asend', 'aclose' and 'athrow' coroutine methods of asynchronous generators.
Diffstat (limited to 'Lib/test/test_asyncio')
-rw-r--r--Lib/test/test_asyncio/test_events.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/Lib/test/test_asyncio/test_events.py b/Lib/test/test_asyncio/test_events.py
index d6489d5..5b32332 100644
--- a/Lib/test/test_asyncio/test_events.py
+++ b/Lib/test/test_asyncio/test_events.py
@@ -2384,8 +2384,6 @@ class HandleTests(test_utils.TestCase):
# (such as ones compiled with Cython).
class Coro:
- __name__ = 'AAA'
-
def send(self, v):
pass
@@ -2399,6 +2397,7 @@ class HandleTests(test_utils.TestCase):
pass
coro = Coro()
+ coro.__name__ = 'AAA'
self.assertTrue(asyncio.iscoroutine(coro))
self.assertEqual(coroutines._format_coroutine(coro), 'AAA()')
@@ -2408,6 +2407,11 @@ class HandleTests(test_utils.TestCase):
coro.cr_running = True
self.assertEqual(coroutines._format_coroutine(coro), 'BBB() running')
+ coro = Coro()
+ # Some coroutines might not have '__name__', such as
+ # built-in async_gen.asend().
+ self.assertEqual(coroutines._format_coroutine(coro), 'Coro()')
+
class TimerTests(unittest.TestCase):