summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorYury Selivanov <yselivanov@sprymix.com>2015-06-24 14:32:22 (GMT)
committerYury Selivanov <yselivanov@sprymix.com>2015-06-24 14:32:22 (GMT)
commit8f1c99321bfe72d21b01bad71293a7daa1c9e73f (patch)
treeef5c6e72f6bf848363e740a3cf2dd1f83cf9b10c /Lib/test
parent3bdbcedfd948bf66a3e2bdaf8180c8e7a262db5f (diff)
parent29a602a1409cc3f6e64a29865ad9d3624bddd35e (diff)
downloadcpython-8f1c99321bfe72d21b01bad71293a7daa1c9e73f.zip
cpython-8f1c99321bfe72d21b01bad71293a7daa1c9e73f.tar.gz
cpython-8f1c99321bfe72d21b01bad71293a7daa1c9e73f.tar.bz2
Issue #24400: Fix CoroWrapper for 'async def' coroutines
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_asyncio/test_pep492.py25
-rw-r--r--Lib/test/test_asyncio/test_tasks.py3
2 files changed, 26 insertions, 2 deletions
diff --git a/Lib/test/test_asyncio/test_pep492.py b/Lib/test/test_asyncio/test_pep492.py
index aa0e2a2..82bb995 100644
--- a/Lib/test/test_asyncio/test_pep492.py
+++ b/Lib/test/test_asyncio/test_pep492.py
@@ -119,7 +119,7 @@ class CoroutineTests(BaseTest):
self.assertEqual(coro.send(None), 'spam')
coro.close()
- def test_async_ded_coroutines(self):
+ def test_async_def_coroutines(self):
async def bar():
return 'spam'
async def foo():
@@ -134,5 +134,28 @@ class CoroutineTests(BaseTest):
data = self.loop.run_until_complete(foo())
self.assertEqual(data, 'spam')
+ @mock.patch('asyncio.coroutines.logger')
+ def test_async_def_wrapped(self, m_log):
+ async def foo():
+ pass
+ async def start():
+ foo_coro = foo()
+ self.assertRegex(
+ repr(foo_coro),
+ r'<CoroWrapper .*\.foo running at .*pep492.*>')
+
+ with support.check_warnings((r'.*foo.*was never',
+ RuntimeWarning)):
+ foo_coro = None
+ support.gc_collect()
+ self.assertTrue(m_log.error.called)
+ message = m_log.error.call_args[0][0]
+ self.assertRegex(message,
+ r'CoroWrapper.*foo.*was never')
+
+ self.loop.set_debug(True)
+ self.loop.run_until_complete(start())
+
+
if __name__ == '__main__':
unittest.main()
diff --git a/Lib/test/test_asyncio/test_tasks.py b/Lib/test/test_asyncio/test_tasks.py
index 6541df7..251192a 100644
--- a/Lib/test/test_asyncio/test_tasks.py
+++ b/Lib/test/test_asyncio/test_tasks.py
@@ -1715,7 +1715,8 @@ class TaskTests(test_utils.TestCase):
self.assertTrue(m_log.error.called)
message = m_log.error.call_args[0][0]
func_filename, func_lineno = test_utils.get_function_source(coro_noop)
- regex = (r'^<CoroWrapper %s\(\) .* at %s:%s, .*> '
+
+ regex = (r'^<CoroWrapper %s\(?\)? .* at %s:%s, .*> '
r'was never yielded from\n'
r'Coroutine object created at \(most recent call last\):\n'
r'.*\n'