File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed
Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change 33from nonebot .adapters import Event
44from nonebot .params import EventParam
55from nonebot .exception import TypeMisMatch
6+ from exceptiongroup import BaseExceptionGroup
67
78from nonebug import App
89
@@ -23,11 +24,20 @@ def _handle_fake(event: FakeEvent): # type: ignore
2324 ctx .pass_params (event = FakeEvent ())
2425
2526 event = FakeEvent2 ()
26- with pytest .raises (TypeMisMatch ) as e :
27+ with pytest .raises (( TypeMisMatch , BaseExceptionGroup )) as exc_info :
2728 async with app .test_dependent (_handle_fake , allow_types = [EventParam ]) as ctx :
2829 ctx .pass_params (event = event )
29- assert e .value .param .name == "event"
30- assert e .value .value is event
30+
31+ if isinstance (exc_info .value , BaseExceptionGroup ):
32+ assert exc_info .group_contains (TypeMisMatch )
33+ exc_group = exc_info .value .subgroup (TypeMisMatch )
34+ e = exc_group .exceptions [0 ] if exc_group else None
35+ assert isinstance (e , TypeMisMatch )
36+ else :
37+ e = exc_info .value
38+
39+ assert e .param .name == "event"
40+ assert e .value is event
3141
3242
3343@pytest .mark .asyncio
You can’t perform that action at this time.
0 commit comments