1- from typing import Union
2-
31import pytest
42from nonebug import App
53from nonebot import get_adapter
119
1210@pytest .mark .asyncio ()
1311async def test_unmatch (app : App ):
14- from nonebot_plugin_alconna import At , Match , UniMessage , on_alconna
12+ from nonebot_plugin_alconna import Match , UniMessage , on_alconna
1513
16- test_cmd = on_alconna (
17- Alconna ("test" , Args ["target" , Union [int , At ]]), skip_for_unmatch = False , auto_send_output = True
18- )
14+ test_cmd = on_alconna (Alconna ("test" , Args ["target" , int ]), skip_for_unmatch = False , auto_send_output = True )
1915
2016 @test_cmd .handle ()
21- async def tt_h (target : Match [Union [ int , At ] ]):
17+ async def tt_h (target : Match [int ]):
2218 await test_cmd .send (UniMessage (["ok\n " , str (target .result )]))
2319
2420 async with app .test_matcher (test_cmd ) as ctx :
@@ -36,4 +32,4 @@ async def tt_h(target: Match[Union[int, At]]):
3632 event = fake_group_message_event_v11 (message = Message ("test abcd" ), user_id = 123 )
3733 ctx .receive_event (bot , event )
3834 ctx .should_not_pass_rule ()
39- ctx .should_call_send (event , "ParamsUnmatched(' 参数 abcd 不正确') " , bot = bot )
35+ ctx .should_call_send (event , "参数 ' abcd' 不正确, 其应该符合 'int' " , bot = bot )
0 commit comments