Skip to content

Commit

Permalink
✅ 更新测试
Browse files Browse the repository at this point in the history
  • Loading branch information
A-kirami committed Sep 12, 2023
1 parent 29677ab commit e3de8f6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
11 changes: 5 additions & 6 deletions tests/plugins/matcher/matcher_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ async def error():
raise RuntimeError


checks = [(falsy, False), (truthy, True), (error, False)]

test_check = MatcherGroup(type="test")
test_check.on(permission=falsy)
test_check.on(permission=truthy)
test_check.on(permission=error)
test_check.on(rule=falsy)
test_check.on(rule=truthy)
test_check.on(rule=error)
for check, result in checks:
test_check.on(permission=check, state={"expect": result})
test_check.on(rule=check, state={"expect": result})
7 changes: 5 additions & 2 deletions tests/test_matcher/test_matcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from nonebot.permission import User
from nonebot.matcher import Matcher, matchers
from utils import FakeMessage, make_fake_event
from nonebot.message import check_and_run_matcher
from nonebot.message import check_and_run_matcher, _check_matcher


@pytest.mark.asyncio
Expand Down Expand Up @@ -319,4 +319,7 @@ async def test_matcher_check(app: App):
async with app.test_api() as ctx:
bot = ctx.create_bot()
for matcher in test_check.matchers:
await check_and_run_matcher(matcher, bot, event, {})
assert (
await _check_matcher(matcher, bot, event, {})
== matcher._default_state["expect"]
)

0 comments on commit e3de8f6

Please sign in to comment.