Skip to content

Commit 844d741

Browse files
authored
✅ fix tests
1 parent 69e5ae1 commit 844d741

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

tests/test_dependent.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from nonebot.adapters import Event
44
from nonebot.params import EventParam
55
from nonebot.exception import TypeMisMatch
6+
from exceptiongroup import BaseExceptionGroup
67

78
from 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

0 commit comments

Comments
 (0)