]> granicus.if.org Git - python/commitdiff
asyncio: sync with Tulip
authorVictor Stinner <victor.stinner@gmail.com>
Wed, 25 Jun 2014 21:32:25 +0000 (23:32 +0200)
committerVictor Stinner <victor.stinner@gmail.com>
Wed, 25 Jun 2014 21:32:25 +0000 (23:32 +0200)
- Python issue 21163: Fix more "Task was destroyed but it is pending!" logs in
  tests
- Add test to check that run_until_complete() checks the loop of the future

Lib/test/test_asyncio/test_base_events.py
Lib/test/test_asyncio/test_tasks.py

index 0aa7a8d16396d5748668afa58d993c5ca02be2e6..6ad0804358880f3612827708ee32c96dee89e2fd 100644 (file)
@@ -288,6 +288,12 @@ class BaseEventLoopTests(test_utils.TestCase):
         self.assertRaises(TypeError,
             self.loop.run_until_complete, 'blah')
 
+    def test_run_until_complete_loop(self):
+        task = asyncio.Future(loop=self.loop)
+        other_loop = self.new_test_loop()
+        self.assertRaises(ValueError,
+            other_loop.run_until_complete, task)
+
     def test_subprocess_exec_invalid_args(self):
         args = [sys.executable, '-c', 'pass']
 
index 3a23d72136378e267ed639442d788ceb374862c7..4508987961768c3a024227140b39ccd271bd8cfb 100644 (file)
@@ -51,6 +51,7 @@ class TaskTests(test_utils.TestCase):
         self.set_event_loop(loop)
         t = asyncio.Task(notmuch(), loop=loop)
         self.assertIs(t._loop, loop)
+        loop.run_until_complete(t)
         loop.close()
 
     def test_async_coroutine(self):
@@ -67,6 +68,7 @@ class TaskTests(test_utils.TestCase):
         self.set_event_loop(loop)
         t = asyncio.async(notmuch(), loop=loop)
         self.assertIs(t._loop, loop)
+        loop.run_until_complete(t)
         loop.close()
 
     def test_async_future(self):
@@ -213,6 +215,7 @@ class TaskTests(test_utils.TestCase):
         t.add_done_callback(Dummy())
         self.assertEqual(repr(t),
                          '<Task pending %s cb=[<Dummy>()]>' % coro)
+        self.loop.run_until_complete(t)
 
     def test_task_basics(self):
         @asyncio.coroutine