MCPcopy
hub / github.com/pydantic/pydantic / test_non_serializable_default

Function test_non_serializable_default

tests/test_json_schema.py:1418–1431  ·  view source on GitHub ↗
(type_, default_value, properties)

Source from the content-addressed store, hash-verified

1416 ),
1417)
1418def test_non_serializable_default(type_, default_value, properties):
1419 class Model(BaseModel):
1420 callback: type_ = default_value
1421
1422 with pytest.warns(
1423 PydanticJsonSchemaWarning,
1424 match=(
1425 'Default value .* is not JSON serializable; excluding default from JSON schema '
1426 r'\[non-serializable-default\]'
1427 ),
1428 ):
1429 model_schema = Model.model_json_schema()
1430 assert model_schema['properties'] == properties
1431 assert model_schema.get('required') is None
1432
1433
1434def test_callable_fallback_with_non_serializable_default():

Callers

nothing calls this directly

Calls 2

model_json_schemaMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected