MCPcopy Index your code
hub / github.com/nonebot/nonebot2 / test_command

Function test_command

tests/test_rule.py:324–343  ·  view source on GitHub ↗
(
    cmds: tuple[tuple[str, ...]],
    force_whitespace: str | bool | None,
    cmd: tuple[str, ...],
    whitespace: str | None,
    arg_text: str | None,
    expected: bool,
)

Source from the content-addressed store, hash-verified

322 ],
323)
324async def test_command(
325 cmds: tuple[tuple[str, ...]],
326 force_whitespace: str | bool | None,
327 cmd: tuple[str, ...],
328 whitespace: str | None,
329 arg_text: str | None,
330 expected: bool,
331):
332 test_command = command(*cmds, force_whitespace=force_whitespace)
333 dependent = next(iter(test_command.checkers))
334 checker = dependent.call
335
336 assert isinstance(checker, CommandRule)
337 assert checker.cmds == cmds
338
339 arg = arg_text if arg_text is None else FakeMessage(arg_text)
340 state = {
341 PREFIX_KEY: {CMD_KEY: cmd, CMD_WHITESPACE_KEY: whitespace, CMD_ARG_KEY: arg}
342 }
343 assert await dependent(state=state) == expected
344
345
346@pytest.mark.anyio

Callers

nothing calls this directly

Calls 2

commandFunction · 0.90
FakeMessageClass · 0.90

Tested by

no test coverage detected