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

Function test_segment_validate

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

Source from the content-addressed store, hash-verified

48
49
50def test_segment_validate():
51 assert type_validate_python(
52 FakeMessageSegment,
53 {"type": "text", "data": {"text": "text"}, "extra": "should be ignored"},
54 ) == FakeMessageSegment.text("text")
55 with pytest.raises(ValidationError):
56 type_validate_python(
57 type("FakeMessageSegment2", (MessageSegment,), {}),
58 FakeMessageSegment.text("text"),
59 )
60
61 with pytest.raises(ValidationError):
62 type_validate_python(FakeMessageSegment, "some str")
63
64 with pytest.raises(ValidationError):
65 type_validate_python(FakeMessageSegment, {"data": {}})
66
67
68def test_segment_join():

Callers

nothing calls this directly

Calls 2

type_validate_pythonFunction · 0.90
textMethod · 0.80

Tested by

no test coverage detected