MCPcopy
hub / github.com/pydantic/pydantic / test_by_alias_generator

Function test_by_alias_generator

tests/test_json_schema.py:178–190  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

176
177
178def test_by_alias_generator():
179 class ApplePie(BaseModel):
180 model_config = ConfigDict(alias_generator=lambda x: x.upper())
181 a: float
182 b: int = 10
183
184 assert ApplePie.model_json_schema() == {
185 'title': 'ApplePie',
186 'type': 'object',
187 'properties': {'A': {'title': 'A', 'type': 'number'}, 'B': {'title': 'B', 'default': 10, 'type': 'integer'}},
188 'required': ['A'],
189 }
190 assert ApplePie.model_json_schema(by_alias=False)['properties'].keys() == {'a', 'b'}
191
192
193def test_sub_model():

Callers

nothing calls this directly

Calls 2

keysMethod · 0.80
model_json_schemaMethod · 0.45

Tested by

no test coverage detected