@@ -230,29 +230,29 @@ async def runner():
230230
231231 self .assertEqual (NUM , 15 )
232232
233- async def test_cancellation_in_body (self ):
233+ async def test_taskgroup_08 (self ):
234234
235235 async def foo ():
236- await asyncio .sleep (0.1 )
237- 1 / 0
236+ try :
237+ await asyncio .sleep (10 )
238+ finally :
239+ 1 / 0
238240
239241 async def runner ():
240242 async with taskgroups .TaskGroup () as g :
241243 for _ in range (5 ):
242244 g .create_task (foo ())
243245
244- try :
245- await asyncio .sleep (10 )
246- except asyncio .CancelledError :
247- raise
246+ await asyncio .sleep (10 )
248247
249248 r = asyncio .create_task (runner ())
250249 await asyncio .sleep (0.1 )
251250
252251 self .assertFalse (r .done ())
253252 r .cancel ()
254- with self .assertRaises (asyncio . CancelledError ) as cm :
253+ with self .assertRaises (ExceptionGroup ) as cm :
255254 await r
255+ self .assertEqual (get_error_types (cm .exception ), {ZeroDivisionError })
256256
257257 async def test_taskgroup_09 (self ):
258258
@@ -316,33 +316,37 @@ async def runner():
316316 async def test_taskgroup_11 (self ):
317317
318318 async def foo ():
319- await asyncio .sleep (0.1 )
320- 1 / 0
319+ try :
320+ await asyncio .sleep (10 )
321+ finally :
322+ 1 / 0
321323
322324 async def runner ():
323325 async with taskgroups .TaskGroup ():
324326 async with taskgroups .TaskGroup () as g2 :
325327 for _ in range (5 ):
326328 g2 .create_task (foo ())
327329
328- try :
329- await asyncio .sleep (10 )
330- except asyncio .CancelledError :
331- raise
330+ await asyncio .sleep (10 )
332331
333332 r = asyncio .create_task (runner ())
334333 await asyncio .sleep (0.1 )
335334
336335 self .assertFalse (r .done ())
337336 r .cancel ()
338- with self .assertRaises (asyncio . CancelledError ) :
337+ with self .assertRaises (ExceptionGroup ) as cm :
339338 await r
340339
340+ self .assertEqual (get_error_types (cm .exception ), {ExceptionGroup })
341+ self .assertEqual (get_error_types (cm .exception .exceptions [0 ]), {ZeroDivisionError })
342+
341343 async def test_taskgroup_12 (self ):
342344
343345 async def foo ():
344- await asyncio .sleep (0.1 )
345- 1 / 0
346+ try :
347+ await asyncio .sleep (10 )
348+ finally :
349+ 1 / 0
346350
347351 async def runner ():
348352 async with taskgroups .TaskGroup () as g1 :
@@ -352,19 +356,19 @@ async def runner():
352356 for _ in range (5 ):
353357 g2 .create_task (foo ())
354358
355- try :
356- await asyncio .sleep (10 )
357- except asyncio .CancelledError :
358- raise
359+ await asyncio .sleep (10 )
359360
360361 r = asyncio .create_task (runner ())
361362 await asyncio .sleep (0.1 )
362363
363364 self .assertFalse (r .done ())
364365 r .cancel ()
365- with self .assertRaises (asyncio . CancelledError ) :
366+ with self .assertRaises (ExceptionGroup ) as cm :
366367 await r
367368
369+ self .assertEqual (get_error_types (cm .exception ), {ExceptionGroup })
370+ self .assertEqual (get_error_types (cm .exception .exceptions [0 ]), {ZeroDivisionError })
371+
368372 async def test_taskgroup_13 (self ):
369373
370374 async def crash_after (t ):
@@ -424,8 +428,9 @@ async def runner():
424428
425429 self .assertFalse (r .done ())
426430 r .cancel ()
427- with self .assertRaises (asyncio . CancelledError ) :
431+ with self .assertRaises (ExceptionGroup ) as cm :
428432 await r
433+ self .assertEqual (get_error_types (cm .exception ), {ZeroDivisionError })
429434
430435 async def test_taskgroup_16 (self ):
431436
@@ -451,8 +456,9 @@ async def runner():
451456
452457 self .assertFalse (r .done ())
453458 r .cancel ()
454- with self .assertRaises (asyncio . CancelledError ) :
459+ with self .assertRaises (ExceptionGroup ) as cm :
455460 await r
461+ self .assertEqual (get_error_types (cm .exception ), {ZeroDivisionError })
456462
457463 async def test_taskgroup_17 (self ):
458464 NUM = 0
0 commit comments