| 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") |