MCPcopy
hub / github.com/pydantic/pydantic / test_field_reuse

Function test_field_reuse

tests/test_annotated.py:148–159  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

146
147
148def test_field_reuse():
149 field = Field(description='Long description')
150
151 class Model(BaseModel):
152 one: int = field
153
154 assert Model(one=1).model_dump() == {'one': 1}
155
156 class AnnotatedModel(BaseModel):
157 one: Annotated[int, field]
158
159 assert AnnotatedModel(one=1).model_dump() == {'one': 1}
160
161
162def test_config_field_info():

Callers

nothing calls this directly

Calls 4

FieldFunction · 0.90
AnnotatedModelClass · 0.85
ModelClass · 0.70
model_dumpMethod · 0.45

Tested by

no test coverage detected