]> granicus.if.org Git - python/commitdiff
bpo-32633: Fix some warnings in test_asyncio.test_tasks (#5280)
authorNathaniel J. Smith <njs@pobox.com>
Tue, 23 Jan 2018 09:09:31 +0000 (01:09 -0800)
committerAndrew Svetlov <andrew.svetlov@gmail.com>
Tue, 23 Jan 2018 09:09:31 +0000 (11:09 +0200)
Lib/test/test_asyncio/test_tasks.py

index 96d2658cb4c7fde4644cf3a65f677f5826d2c8dc..1c361c8ec17c624bcd4ec2088a141fe4a7099c9d 100644 (file)
@@ -2342,7 +2342,8 @@ class SetMethodsTest:
             await asyncio.sleep(0.1, loop=self.loop)
             return 10
 
-        task = self.new_task(self.loop, foo())
+        coro = foo()
+        task = self.new_task(self.loop, coro)
         Future.set_result(task, 'spam')
 
         self.assertEqual(
@@ -2355,6 +2356,8 @@ class SetMethodsTest:
                                     r'step\(\): already done'):
             raise exc
 
+        coro.close()
+
     def test_set_exception_causes_invalid_state(self):
         class MyExc(Exception):
             pass
@@ -2366,7 +2369,8 @@ class SetMethodsTest:
             await asyncio.sleep(0.1, loop=self.loop)
             return 10
 
-        task = self.new_task(self.loop, foo())
+        coro = foo()
+        task = self.new_task(self.loop, coro)
         Future.set_exception(task, MyExc())
 
         with self.assertRaises(MyExc):
@@ -2378,6 +2382,8 @@ class SetMethodsTest:
                                     r'step\(\): already done'):
             raise exc
 
+        coro.close()
+
 
 @unittest.skipUnless(hasattr(futures, '_CFuture') and
                      hasattr(tasks, '_CTask'),