🐛 fix event maybe converted when checking type (#876)

Fix: 修复 event 类型检查会对类型进行自动转换
This commit is contained in:
Ju4tCode
2022-03-20 19:40:43 +08:00
committed by GitHub
parent fcdb05a7e2
commit 45e2e6c280
6 changed files with 53 additions and 20 deletions

View File

@ -35,11 +35,8 @@ async def test_get(monkeypatch: pytest.MonkeyPatch, nonebug_clear):
from nonebot.drivers import ForwardDriver, ReverseDriver
from nonebot import get_app, get_bot, get_asgi, get_bots, get_driver
try:
with pytest.raises(ValueError):
get_driver()
assert False, "Driver can only be got after initialization"
except ValueError:
assert True
nonebot.init(driver="nonebot.drivers.fastapi")
@ -59,11 +56,8 @@ async def test_get(monkeypatch: pytest.MonkeyPatch, nonebug_clear):
nonebot.run("arg", kwarg="kwarg")
assert runned
try:
with pytest.raises(ValueError):
get_bot()
assert False
except ValueError:
assert True
monkeypatch.setattr(driver, "_clients", {"test": "test"})
assert get_bot() == "test"