MCPcopy
hub / github.com/pydantic/pydantic / test_custom_iso_timedelta

Function test_custom_iso_timedelta

tests/test_json.py:417–423  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

415
416
417def test_custom_iso_timedelta():
418 class Model(BaseModel):
419 x: timedelta
420 model_config = ConfigDict(json_encoders={timedelta: lambda _: 'P0DT0H2M3.000000S'})
421
422 m = Model(x=321)
423 assert json.loads(m.model_dump_json()) == {'x': 'P0DT0H2M3.000000S'}
424
425
426def test_json_encoders_config_simple_inheritance():

Callers

nothing calls this directly

Calls 2

model_dump_jsonMethod · 0.80
ModelClass · 0.70

Tested by

no test coverage detected