1# IsolatedAsyncioTestCase based tests 2import asyncio 3import unittest 4 5 6def tearDownModule(): 7 asyncio.set_event_loop_policy(None) 8 9 10class FutureTests(unittest.IsolatedAsyncioTestCase): 11 async def test_recursive_repr_for_pending_tasks(self): 12 # The call crashes if the guard for recursive call 13 # in base_futures:_future_repr_info is absent 14 # See Also: https://bugs.python.org/issue42183 15 16 async def func(): 17 return asyncio.all_tasks() 18 19 # The repr() call should not raise RecursiveError at first. 20 # The check for returned string is not very reliable but 21 # exact comparison for the whole string is even weaker. 22 self.assertIn('...', repr(await asyncio.wait_for(func(), timeout=10))) 23 24 25if __name__ == '__main__': 26 unittest.main() 27