MCPcopy
hub / github.com/nonebot/nonebot2 / disconn_hook

Function disconn_hook

tests/test_driver.py:936–948  ·  view source on GitHub ↗
(
            foo: Bot, dep: int = Depends(dependency), default: int = 1
        )

Source from the content-addressed store, hash-verified

934
935 @driver.on_bot_disconnect
936 async def disconn_hook(
937 foo: Bot, dep: int = Depends(dependency), default: int = 1
938 ):
939 nonlocal disconn_should_be_called
940
941 if foo is not bot:
942 pytest.fail("on_bot_disconnect hook called with wrong bot")
943 if dep != 1:
944 pytest.fail("on_bot_connect hook called with wrong dependency")
945 if default != 1:
946 pytest.fail("on_bot_connect hook called with wrong default value")
947
948 disconn_should_be_called = True
949
950 if conn_hook not in {hook.call for hook in conn_hooks}: # type: ignore
951 pytest.fail("on_bot_connect hook not registered")

Callers

nothing calls this directly

Calls 1

DependsFunction · 0.90

Tested by

no test coverage detected