@@ -843,82 +843,6 @@ async def test_taskgroup_without_parent_task(self):
843843 # We still have to await coro to avoid a warning
844844 await coro
845845
846- async def test_coro_closed_when_tg_closed (self ):
847- async def run_coro_after_tg_closes ():
848- async with taskgroups .TaskGroup () as tg :
849- pass
850- coro = asyncio .sleep (0 )
851- with self .assertRaisesRegex (RuntimeError , "is finished" ):
852- tg .create_task (coro )
853-
854- await run_coro_after_tg_closes ()
855-
856- async def test_cancelling_level_preserved (self ):
857- async def raise_after (t , e ):
858- await asyncio .sleep (t )
859- raise e ()
860-
861- try :
862- async with asyncio .TaskGroup () as tg :
863- tg .create_task (raise_after (0.0 , RuntimeError ))
864- except* RuntimeError :
865- pass
866- self .assertEqual (asyncio .current_task ().cancelling (), 0 )
867-
868- async def test_nested_groups_both_cancelled (self ):
869- async def raise_after (t , e ):
870- await asyncio .sleep (t )
871- raise e ()
872-
873- try :
874- async with asyncio .TaskGroup () as outer_tg :
875- try :
876- async with asyncio .TaskGroup () as inner_tg :
877- inner_tg .create_task (raise_after (0 , RuntimeError ))
878- outer_tg .create_task (raise_after (0 , ValueError ))
879- except* RuntimeError :
880- pass
881- else :
882- self .fail ("RuntimeError not raised" )
883- self .assertEqual (asyncio .current_task ().cancelling (), 1 )
884- except* ValueError :
885- pass
886- else :
887- self .fail ("ValueError not raised" )
888- self .assertEqual (asyncio .current_task ().cancelling (), 0 )
889-
890- async def test_error_and_cancel (self ):
891- event = asyncio .Event ()
892-
893- async def raise_error ():
894- event .set ()
895- await asyncio .sleep (0 )
896- raise RuntimeError ()
897-
898- async def inner ():
899- try :
900- async with taskgroups .TaskGroup () as tg :
901- tg .create_task (raise_error ())
902- await asyncio .sleep (1 )
903- self .fail ("Sleep in group should have been cancelled" )
904- except* RuntimeError :
905- self .assertEqual (asyncio .current_task ().cancelling (), 1 )
906- self .assertEqual (asyncio .current_task ().cancelling (), 1 )
907- await asyncio .sleep (1 )
908- self .fail ("Sleep after group should have been cancelled" )
909-
910- async def outer ():
911- t = asyncio .create_task (inner ())
912- await event .wait ()
913- self .assertEqual (t .cancelling (), 0 )
914- t .cancel ()
915- self .assertEqual (t .cancelling (), 1 )
916- with self .assertRaises (asyncio .CancelledError ):
917- await t
918- self .assertTrue (t .cancelled ())
919-
920- await outer ()
921-
922846 async def test_exception_refcycles_direct (self ):
923847 """Test that TaskGroup doesn't keep a reference to the raised ExceptionGroup"""
924848 tg = asyncio .TaskGroup ()
0 commit comments