mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 05:31:20 +00:00 
			
		
		
		
	fix various warnings in test_asyncio.test_tasks (#131109)
				
					
				
			This commit is contained in:
		
							parent
							
								
									8b1edae93a
								
							
						
					
					
						commit
						fcf756adef
					
				
					 1 changed files with 6 additions and 3 deletions
				
			
		|  | @ -2301,16 +2301,19 @@ class Subclass(Task): | ||||||
|             def __del__(self): |             def __del__(self): | ||||||
|                 pass |                 pass | ||||||
| 
 | 
 | ||||||
|         async def coro(): |         async def corofn(): | ||||||
|             await asyncio.sleep(0.01) |             await asyncio.sleep(0.01) | ||||||
| 
 | 
 | ||||||
|         task = Subclass(coro(), loop = self.loop) |         coro = corofn() | ||||||
|  |         task = Subclass(coro, loop = self.loop) | ||||||
|         task._log_destroy_pending = False |         task._log_destroy_pending = False | ||||||
| 
 | 
 | ||||||
|         del task |         del task | ||||||
| 
 | 
 | ||||||
|         support.gc_collect() |         support.gc_collect() | ||||||
| 
 | 
 | ||||||
|  |         coro.close() | ||||||
|  | 
 | ||||||
|     @mock.patch('asyncio.base_events.logger') |     @mock.patch('asyncio.base_events.logger') | ||||||
|     def test_tb_logger_not_called_after_cancel(self, m_log): |     def test_tb_logger_not_called_after_cancel(self, m_log): | ||||||
|         loop = asyncio.new_event_loop() |         loop = asyncio.new_event_loop() | ||||||
|  | @ -2716,12 +2719,12 @@ def __str__(self): | ||||||
|         coro = coroutine_function() |         coro = coroutine_function() | ||||||
|         with contextlib.closing(asyncio.EventLoop()) as loop: |         with contextlib.closing(asyncio.EventLoop()) as loop: | ||||||
|             task = asyncio.Task.__new__(asyncio.Task) |             task = asyncio.Task.__new__(asyncio.Task) | ||||||
| 
 |  | ||||||
|             for _ in range(5): |             for _ in range(5): | ||||||
|                 with self.assertRaisesRegex(RuntimeError, 'break'): |                 with self.assertRaisesRegex(RuntimeError, 'break'): | ||||||
|                     task.__init__(coro, loop=loop, context=obj, name=Break()) |                     task.__init__(coro, loop=loop, context=obj, name=Break()) | ||||||
| 
 | 
 | ||||||
|             coro.close() |             coro.close() | ||||||
|  |             task._log_destroy_pending = False | ||||||
|             del task |             del task | ||||||
| 
 | 
 | ||||||
|             self.assertEqual(sys.getrefcount(obj), initial_refcount) |             self.assertEqual(sys.getrefcount(obj), initial_refcount) | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Kumar Aditya
						Kumar Aditya