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

Function test_aliased_state

tests/test_param.py:518–542  ·  view source on GitHub ↗
(app: App)

Source from the content-addressed store, hash-verified

516 sys.version_info < (3, 12), reason="TypeAlias requires Python 3.12 or higher"
517)
518async def test_aliased_state(app: App):
519 from python_3_12.plugins.aliased_param.param_state import aliased_state
520
521 fake_message = FakeMessage("text")
522 fake_matched = re.match(r"\[cq:(?P<type>.*?),(?P<arg>.*?)\]", "[cq:test,arg=value]")
523 fake_state = {
524 PREFIX_KEY: {
525 CMD_KEY: ("cmd",),
526 RAW_CMD_KEY: "/cmd",
527 CMD_START_KEY: "/",
528 CMD_ARG_KEY: fake_message,
529 CMD_WHITESPACE_KEY: " ",
530 },
531 SHELL_ARGV: ["-h"],
532 SHELL_ARGS: {"help": True},
533 REGEX_MATCHED: fake_matched,
534 STARTSWITH_KEY: "startswith",
535 ENDSWITH_KEY: "endswith",
536 FULLMATCH_KEY: "fullmatch",
537 KEYWORD_KEY: "keyword",
538 }
539
540 async with app.test_dependent(aliased_state, allow_types=[StateParam]) as ctx:
541 ctx.pass_params(state=fake_state)
542 ctx.should_return(fake_state)
543
544
545@pytest.mark.anyio

Callers

nothing calls this directly

Calls 1

FakeMessageClass · 0.90

Tested by

no test coverage detected