MCPcopy
hub / github.com/pydantic/pydantic / test_parse_obj_preserves_subclasses

Function test_parse_obj_preserves_subclasses

tests/test_tools.py:28–38  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

26
27
28def test_parse_obj_preserves_subclasses():
29 class ModelA(BaseModel):
30 a: Mapping[int, str]
31
32 class ModelB(ModelA):
33 b: int
34
35 model_b = ModelB(a={1: 'f'}, b=2)
36
37 parsed = parse_obj_as(list[ModelA], [model_b])
38 assert parsed == [model_b]
39
40
41def test_parse_obj_fails():

Callers

nothing calls this directly

Calls 2

parse_obj_asFunction · 0.90
ModelBClass · 0.70

Tested by

no test coverage detected