mirror of
				https://github.com/python/cpython.git
				synced 2025-11-03 19:34:08 +00:00 
			
		
		
		
	asyncio: sync with Tulip
- 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
This commit is contained in:
		
							parent
							
								
									87f16f892c
								
							
						
					
					
						commit
						7ba4061098
					
				
					 2 changed files with 9 additions and 0 deletions
				
			
		| 
						 | 
					@ -288,6 +288,12 @@ class BaseEventLoopTests(test_utils.TestCase):
 | 
				
			||||||
        self.assertRaises(TypeError,
 | 
					        self.assertRaises(TypeError,
 | 
				
			||||||
            self.loop.run_until_complete, 'blah')
 | 
					            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):
 | 
					    def test_subprocess_exec_invalid_args(self):
 | 
				
			||||||
        args = [sys.executable, '-c', 'pass']
 | 
					        args = [sys.executable, '-c', 'pass']
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -51,6 +51,7 @@ class TaskTests(test_utils.TestCase):
 | 
				
			||||||
        self.set_event_loop(loop)
 | 
					        self.set_event_loop(loop)
 | 
				
			||||||
        t = asyncio.Task(notmuch(), loop=loop)
 | 
					        t = asyncio.Task(notmuch(), loop=loop)
 | 
				
			||||||
        self.assertIs(t._loop, loop)
 | 
					        self.assertIs(t._loop, loop)
 | 
				
			||||||
 | 
					        loop.run_until_complete(t)
 | 
				
			||||||
        loop.close()
 | 
					        loop.close()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def test_async_coroutine(self):
 | 
					    def test_async_coroutine(self):
 | 
				
			||||||
| 
						 | 
					@ -67,6 +68,7 @@ class TaskTests(test_utils.TestCase):
 | 
				
			||||||
        self.set_event_loop(loop)
 | 
					        self.set_event_loop(loop)
 | 
				
			||||||
        t = asyncio.async(notmuch(), loop=loop)
 | 
					        t = asyncio.async(notmuch(), loop=loop)
 | 
				
			||||||
        self.assertIs(t._loop, loop)
 | 
					        self.assertIs(t._loop, loop)
 | 
				
			||||||
 | 
					        loop.run_until_complete(t)
 | 
				
			||||||
        loop.close()
 | 
					        loop.close()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def test_async_future(self):
 | 
					    def test_async_future(self):
 | 
				
			||||||
| 
						 | 
					@ -213,6 +215,7 @@ class TaskTests(test_utils.TestCase):
 | 
				
			||||||
        t.add_done_callback(Dummy())
 | 
					        t.add_done_callback(Dummy())
 | 
				
			||||||
        self.assertEqual(repr(t),
 | 
					        self.assertEqual(repr(t),
 | 
				
			||||||
                         '<Task pending %s cb=[<Dummy>()]>' % coro)
 | 
					                         '<Task pending %s cb=[<Dummy>()]>' % coro)
 | 
				
			||||||
 | 
					        self.loop.run_until_complete(t)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def test_task_basics(self):
 | 
					    def test_task_basics(self):
 | 
				
			||||||
        @asyncio.coroutine
 | 
					        @asyncio.coroutine
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue