📝 Docs: 修复单元测试示例代码 (#2741)

This commit is contained in:
mobyw 2024-05-30 14:13:11 +08:00 committed by GitHub
parent c769f95688
commit 38e42919b7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 32 additions and 32 deletions

View File

@ -150,7 +150,7 @@ async def test_weather(app: App):
time=datetime.now(), time=datetime.now(),
self_id="test", self_id="test",
message=Message("/天气 北京"), message=Message("/天气 北京"),
user=User(user_id=123456789), user=User(id="user"),
) )
``` ```
@ -165,7 +165,7 @@ async def test_weather(app: App):
time=datetime.now(), time=datetime.now(),
self_id="test", self_id="test",
message=Message("/天气 北京"), message=Message("/天气 北京"),
user=User(user_id=123456789), user=User(id="user"),
) )
async with app.test_matcher(weather) as ctx: async with app.test_matcher(weather) as ctx:
bot = ctx.create_bot() bot = ctx.create_bot()
@ -184,7 +184,7 @@ def make_event(message: str = "") -> MessageEvent:
time=datetime.now(), time=datetime.now(),
self_id="test", self_id="test",
message=Message(message), message=Message(message),
user=User(user_id=123456789), user=User(id="user"),
) )
@pytest.mark.asyncio @pytest.mark.asyncio

View File

@ -56,7 +56,7 @@ def make_event(message: str = "") -> MessageEvent:
time=datetime.now(), time=datetime.now(),
self_id="test", self_id="test",
message=Message(message), message=Message(message),
user=User(user_id=123456789), user=User(id="user"),
) )
@pytest.mark.asyncio @pytest.mark.asyncio
@ -95,7 +95,7 @@ def make_event(message: str = "") -> MessageEvent:
time=datetime.now(), time=datetime.now(),
self_id="test", self_id="test",
message=Message(message), message=Message(message),
user=User(user_id=123456789), user=User(id="user"),
) )
@pytest.mark.asyncio @pytest.mark.asyncio
@ -131,7 +131,7 @@ def make_event(message: str = "") -> MessageEvent:
time=datetime.now(), time=datetime.now(),
self_id="test", self_id="test",
message=Message(message), message=Message(message),
user=User(user_id=123456789), user=User(id="user"),
) )
@pytest.mark.asyncio @pytest.mark.asyncio
@ -202,7 +202,7 @@ def make_event(message: str = "") -> MessageEvent:
time=datetime.now(), time=datetime.now(),
self_id="test", self_id="test",
message=Message(message), message=Message(message),
user=User(user_id=123456789), user=User(id="user"),
) )
@pytest.mark.asyncio @pytest.mark.asyncio
@ -264,7 +264,7 @@ def make_event(message: str = "") -> MessageEvent:
time=datetime.now(), time=datetime.now(),
self_id="test", self_id="test",
message=Message(message), message=Message(message),
user=User(user_id=123456789), user=User(id="user"),
) )
@pytest.mark.asyncio @pytest.mark.asyncio

View File

@ -150,7 +150,7 @@ async def test_weather(app: App):
time=datetime.now(), time=datetime.now(),
self_id="test", self_id="test",
message=Message("/天气 北京"), message=Message("/天气 北京"),
user=User(user_id=123456789), user=User(id="user"),
) )
``` ```
@ -165,7 +165,7 @@ async def test_weather(app: App):
time=datetime.now(), time=datetime.now(),
self_id="test", self_id="test",
message=Message("/天气 北京"), message=Message("/天气 北京"),
user=User(user_id=123456789), user=User(id="user"),
) )
async with app.test_matcher(weather) as ctx: async with app.test_matcher(weather) as ctx:
bot = ctx.create_bot() bot = ctx.create_bot()
@ -184,7 +184,7 @@ def make_event(message: str = "") -> MessageEvent:
time=datetime.now(), time=datetime.now(),
self_id="test", self_id="test",
message=Message(message), message=Message(message),
user=User(user_id=123456789), user=User(id="user"),
) )
@pytest.mark.asyncio @pytest.mark.asyncio

View File

@ -56,7 +56,7 @@ def make_event(message: str = "") -> MessageEvent:
time=datetime.now(), time=datetime.now(),
self_id="test", self_id="test",
message=Message(message), message=Message(message),
user=User(user_id=123456789), user=User(id="user"),
) )
@pytest.mark.asyncio @pytest.mark.asyncio
@ -95,7 +95,7 @@ def make_event(message: str = "") -> MessageEvent:
time=datetime.now(), time=datetime.now(),
self_id="test", self_id="test",
message=Message(message), message=Message(message),
user=User(user_id=123456789), user=User(id="user"),
) )
@pytest.mark.asyncio @pytest.mark.asyncio
@ -131,7 +131,7 @@ def make_event(message: str = "") -> MessageEvent:
time=datetime.now(), time=datetime.now(),
self_id="test", self_id="test",
message=Message(message), message=Message(message),
user=User(user_id=123456789), user=User(id="user"),
) )
@pytest.mark.asyncio @pytest.mark.asyncio
@ -202,7 +202,7 @@ def make_event(message: str = "") -> MessageEvent:
time=datetime.now(), time=datetime.now(),
self_id="test", self_id="test",
message=Message(message), message=Message(message),
user=User(user_id=123456789), user=User(id="user"),
) )
@pytest.mark.asyncio @pytest.mark.asyncio
@ -264,7 +264,7 @@ def make_event(message: str = "") -> MessageEvent:
time=datetime.now(), time=datetime.now(),
self_id="test", self_id="test",
message=Message(message), message=Message(message),
user=User(user_id=123456789), user=User(id="user"),
) )
@pytest.mark.asyncio @pytest.mark.asyncio

View File

@ -150,7 +150,7 @@ async def test_weather(app: App):
time=datetime.now(), time=datetime.now(),
self_id="test", self_id="test",
message=Message("/天气 北京"), message=Message("/天气 北京"),
user=User(user_id=123456789), user=User(id="user"),
) )
``` ```
@ -165,7 +165,7 @@ async def test_weather(app: App):
time=datetime.now(), time=datetime.now(),
self_id="test", self_id="test",
message=Message("/天气 北京"), message=Message("/天气 北京"),
user=User(user_id=123456789), user=User(id="user"),
) )
async with app.test_matcher(weather) as ctx: async with app.test_matcher(weather) as ctx:
bot = ctx.create_bot() bot = ctx.create_bot()
@ -184,7 +184,7 @@ def make_event(message: str = "") -> MessageEvent:
time=datetime.now(), time=datetime.now(),
self_id="test", self_id="test",
message=Message(message), message=Message(message),
user=User(user_id=123456789), user=User(id="user"),
) )
@pytest.mark.asyncio @pytest.mark.asyncio

View File

@ -56,7 +56,7 @@ def make_event(message: str = "") -> MessageEvent:
time=datetime.now(), time=datetime.now(),
self_id="test", self_id="test",
message=Message(message), message=Message(message),
user=User(user_id=123456789), user=User(id="user"),
) )
@pytest.mark.asyncio @pytest.mark.asyncio
@ -95,7 +95,7 @@ def make_event(message: str = "") -> MessageEvent:
time=datetime.now(), time=datetime.now(),
self_id="test", self_id="test",
message=Message(message), message=Message(message),
user=User(user_id=123456789), user=User(id="user"),
) )
@pytest.mark.asyncio @pytest.mark.asyncio
@ -131,7 +131,7 @@ def make_event(message: str = "") -> MessageEvent:
time=datetime.now(), time=datetime.now(),
self_id="test", self_id="test",
message=Message(message), message=Message(message),
user=User(user_id=123456789), user=User(id="user"),
) )
@pytest.mark.asyncio @pytest.mark.asyncio
@ -202,7 +202,7 @@ def make_event(message: str = "") -> MessageEvent:
time=datetime.now(), time=datetime.now(),
self_id="test", self_id="test",
message=Message(message), message=Message(message),
user=User(user_id=123456789), user=User(id="user"),
) )
@pytest.mark.asyncio @pytest.mark.asyncio
@ -264,7 +264,7 @@ def make_event(message: str = "") -> MessageEvent:
time=datetime.now(), time=datetime.now(),
self_id="test", self_id="test",
message=Message(message), message=Message(message),
user=User(user_id=123456789), user=User(id="user"),
) )
@pytest.mark.asyncio @pytest.mark.asyncio

View File

@ -150,7 +150,7 @@ async def test_weather(app: App):
time=datetime.now(), time=datetime.now(),
self_id="test", self_id="test",
message=Message("/天气 北京"), message=Message("/天气 北京"),
user=User(user_id=123456789), user=User(id="user"),
) )
``` ```
@ -165,7 +165,7 @@ async def test_weather(app: App):
time=datetime.now(), time=datetime.now(),
self_id="test", self_id="test",
message=Message("/天气 北京"), message=Message("/天气 北京"),
user=User(user_id=123456789), user=User(id="user"),
) )
async with app.test_matcher(weather) as ctx: async with app.test_matcher(weather) as ctx:
bot = ctx.create_bot() bot = ctx.create_bot()
@ -184,7 +184,7 @@ def make_event(message: str = "") -> MessageEvent:
time=datetime.now(), time=datetime.now(),
self_id="test", self_id="test",
message=Message(message), message=Message(message),
user=User(user_id=123456789), user=User(id="user"),
) )
@pytest.mark.asyncio @pytest.mark.asyncio

View File

@ -56,7 +56,7 @@ def make_event(message: str = "") -> MessageEvent:
time=datetime.now(), time=datetime.now(),
self_id="test", self_id="test",
message=Message(message), message=Message(message),
user=User(user_id=123456789), user=User(id="user"),
) )
@pytest.mark.asyncio @pytest.mark.asyncio
@ -95,7 +95,7 @@ def make_event(message: str = "") -> MessageEvent:
time=datetime.now(), time=datetime.now(),
self_id="test", self_id="test",
message=Message(message), message=Message(message),
user=User(user_id=123456789), user=User(id="user"),
) )
@pytest.mark.asyncio @pytest.mark.asyncio
@ -131,7 +131,7 @@ def make_event(message: str = "") -> MessageEvent:
time=datetime.now(), time=datetime.now(),
self_id="test", self_id="test",
message=Message(message), message=Message(message),
user=User(user_id=123456789), user=User(id="user"),
) )
@pytest.mark.asyncio @pytest.mark.asyncio
@ -202,7 +202,7 @@ def make_event(message: str = "") -> MessageEvent:
time=datetime.now(), time=datetime.now(),
self_id="test", self_id="test",
message=Message(message), message=Message(message),
user=User(user_id=123456789), user=User(id="user"),
) )
@pytest.mark.asyncio @pytest.mark.asyncio
@ -264,7 +264,7 @@ def make_event(message: str = "") -> MessageEvent:
time=datetime.now(), time=datetime.now(),
self_id="test", self_id="test",
message=Message(message), message=Message(message),
user=User(user_id=123456789), user=User(id="user"),
) )
@pytest.mark.asyncio @pytest.mark.asyncio