add test cases

This commit is contained in:
yanyongyu
2021-12-20 00:28:02 +08:00
parent ca045b2f73
commit c2c3d5ef4b
17 changed files with 432 additions and 55 deletions

View File

@ -0,0 +1,30 @@
from nonebot import on_message
from nonebot.adapters import Event
from nonebot.params import Depends
test_depends = on_message()
runned = []
def dependency():
runned.append(1)
return 1
def parameterless():
assert len(runned) == 0
runned.append(1)
# test parameterless
@test_depends.handle(parameterless=[Depends(parameterless)])
async def depends(x: int = Depends(dependency)):
# test dependency
return x
@test_depends.handle()
async def depends_cache(y: int = Depends(dependency, use_cache=True)):
# test cache
return y