File tree Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change 1
1
from __future__ import annotations
2
+ import sys
3
+
4
+ if sys .version_info < (3 , 11 ):
5
+ from exceptiongroup import ExceptionGroup
2
6
3
7
import pytest
4
8
import trio
@@ -24,9 +28,17 @@ async def test_startup_timeout_error(nursery: trio._core._run.Nursery) -> None:
24
28
@pytest .mark .trio
25
29
async def test_startup_failure () -> None :
26
30
lifespan = Lifespan (ASGIWrapper (lifespan_failure ), Config ())
31
+
27
32
with pytest .raises (LifespanFailureError ) as exc_info :
28
- async with trio .open_nursery () as lifespan_nursery :
29
- await lifespan_nursery .start (lifespan .handle_lifespan )
30
- await lifespan .wait_for_startup ()
33
+ try :
34
+ async with trio .open_nursery () as lifespan_nursery :
35
+ await lifespan_nursery .start (lifespan .handle_lifespan )
36
+ await lifespan .wait_for_startup ()
37
+ except ExceptionGroup as exception :
38
+ target_exception = exception
39
+ if len (exception .exceptions ) == 1 :
40
+ target_exception = exception .exceptions [0 ]
41
+
42
+ raise target_exception .with_traceback (target_exception .__traceback__ )
31
43
32
44
assert str (exc_info .value ) == "Lifespan failure in startup. 'Failure'"
You can’t perform that action at this time.
0 commit comments