-
-
Notifications
You must be signed in to change notification settings - Fork 579
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: bot.call_api 在被 called api hook mock 后应该忽略 exception #2374
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2374 +/- ##
==========================================
+ Coverage 90.81% 91.65% +0.84%
==========================================
Files 46 46
Lines 3428 3429 +1
==========================================
+ Hits 3113 3143 +30
+ Misses 315 286 -29
Flags with carried forward coverage won't be shown. Click here to find out more.
|
🚀 Deployed on https://deploy-preview-2374--nonebot2.netlify.app |
请补充一下测试用例 |
nonebug 似乎没有检验 @pytest.mark.asyncio
async def test_on_called_api_mocked(app: App, monkeypatch: pytest.MonkeyPatch):
runned = False
async def test_on_called_api_hook(
bot: Bot,
exception: Optional[Exception],
api: str,
data: Dict[str, Any],
result: Any,
):
nonlocal runned
runned = True
raise MockApiException(result={"mocked": True})
async def test_call_api_handler(bot: Bot):
await bot.call_api("test", test=True)
with app.provider.context({}):
matcher = on_message()
matcher.handle()(test_call_api_handler)
async with app.test_matcher(matcher) as ctx:
bot = ctx.create_bot()
bot.on_called_api(test_on_called_api_hook)
event = make_fake_event()()
ctx.receive_event(bot, event)
ctx.should_call_api("test", {"test": True}, {"mocked": True})
assert runned, "on_called_api_hook should runned" nonebug 这里对 |
fix #2373