code: def test_cancellation_hanging_tasks(self):
      cancelled = False
  
      class Test(unittest.IsolatedAsyncioTestCase):
          async def test_leaking_task(self):
              async def coro():
                  nonlocal cancelled
                  try:
                      await asyncio.sleep(1)
                  except asyncio.CancelledError:
                      cancelled = True
                      raise
  
              # Leave this running in the background
              asyncio.create_task(coro())
  
      test = Test("test_leaking_task")
      output = test.run()
      self.assertTrue(cancelled)
  
imports: import asyncio
  import contextvars
  import unittest
  from test import support
label_desc: Use image node_id 10 for calling the TestAsyncCase obj's underlying member method code with example usage: obj.test_cancellation_hanging_tasks() without return types