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

Function test_rich_template_message

tests/test_adapters/test_template.py:36–50  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

34
35
36def test_rich_template_message():
37 pic1, pic2, pic3 = (
38 FakeMessageSegment.image("file:///pic1.jpg"),
39 FakeMessageSegment.image("file:///pic2.jpg"),
40 FakeMessageSegment.image("file:///pic3.jpg"),
41 )
42
43 template = FakeMessage.template("{}{}" + pic2 + "{}")
44
45 result = template.format(pic1, "[fake:image]", pic3)
46
47 assert result["image"] == FakeMessage([pic1, pic2, pic3])
48 assert str(result) == (
49 "[fake:image]" + escape_text("[fake:image]") + "[fake:image]" + "[fake:image]"
50 )
51
52
53def test_message_injection():

Callers

nothing calls this directly

Calls 5

FakeMessageClass · 0.90
escape_textFunction · 0.90
imageMethod · 0.80
templateMethod · 0.80
formatMethod · 0.80

Tested by

no test coverage detected