mirror of
https://github.com/nonebot/nonebot2.git
synced 2025-09-06 20:16:47 +00:00
🐛 fix arg message store
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
from nonebot.adapters import Event, Message
|
||||
from nonebot.params import Arg, ArgStr, ArgEvent
|
||||
from nonebot.params import Arg, ArgStr, ArgPlainText
|
||||
|
||||
|
||||
async def arg(key: Message = Arg()) -> Message:
|
||||
@ -10,5 +10,5 @@ async def arg_str(key: str = ArgStr()) -> str:
|
||||
return key
|
||||
|
||||
|
||||
async def arg_event(key: Event = ArgEvent()) -> Event:
|
||||
async def arg_plain_text(key: str = ArgPlainText()) -> str:
|
||||
return key
|
||||
|
@ -216,12 +216,11 @@ async def test_arg(app: App, load_plugin):
|
||||
from nonebot.matcher import Matcher
|
||||
from nonebot.params import ArgParam
|
||||
|
||||
from plugins.param.param_arg import arg, arg_str, arg_event
|
||||
from plugins.param.param_arg import arg, arg_str, arg_plain_text
|
||||
|
||||
matcher = Matcher()
|
||||
message = make_fake_message()("text")
|
||||
event = make_fake_event(_message=message)()
|
||||
matcher.set_arg("key", event)
|
||||
matcher.set_arg("key", message)
|
||||
|
||||
async with app.test_dependent(arg, allow_types=[ArgParam]) as ctx:
|
||||
ctx.pass_params(matcher=matcher)
|
||||
@ -231,9 +230,9 @@ async def test_arg(app: App, load_plugin):
|
||||
ctx.pass_params(matcher=matcher)
|
||||
ctx.should_return(str(message))
|
||||
|
||||
async with app.test_dependent(arg_event, allow_types=[ArgParam]) as ctx:
|
||||
async with app.test_dependent(arg_plain_text, allow_types=[ArgParam]) as ctx:
|
||||
ctx.pass_params(matcher=matcher)
|
||||
ctx.should_return(event)
|
||||
ctx.should_return(message.extract_plain_text())
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
Reference in New Issue
Block a user