]> granicus.if.org Git - python/commitdiff
bpo-32676, test_asyncio: Fix warning in test_error_in_call_soon() (GH-7462)
authorVictor Stinner <vstinner@redhat.com>
Wed, 6 Jun 2018 23:30:38 +0000 (01:30 +0200)
committerGitHub <noreply@github.com>
Wed, 6 Jun 2018 23:30:38 +0000 (01:30 +0200)
Fix "<CoroWrapper ...> was never yielded from" warning in
PyTask_PyFuture_Tests.test_error_in_call_soon() of
test_asyncio.test_tasks.

Close manually the coroutine on error.

Lib/test/test_asyncio/test_tasks.py

index 1079d49a402157d7f3774c0e46224ab33002b107..a5442f5fdfff8fe33684e0b4f745f53881a01735 100644 (file)
@@ -2182,7 +2182,11 @@ class BaseTaskTests:
         self.assertFalse(m_log.error.called)
 
         with self.assertRaises(ValueError):
-            self.new_task(self.loop, coro())
+            gen = coro()
+            try:
+                self.new_task(self.loop, gen)
+            finally:
+                gen.close()
 
         self.assertTrue(m_log.error.called)
         message = m_log.error.call_args[0][0]