test_encode_custom_json_encoders_model_pydanticv2() — fastapi Function Reference
Architecture documentation for the test_encode_custom_json_encoders_model_pydanticv2() function in test_jsonable_encoder.py from the fastapi codebase.
Entity Profile
Dependency Diagram
graph TD a3bb3705_7383_2a9b_2bd8_7b9eb6335743["test_encode_custom_json_encoders_model_pydanticv2()"] 80ce950d_4c72_e7d9_21bb_a5c60524786c["test_jsonable_encoder.py"] a3bb3705_7383_2a9b_2bd8_7b9eb6335743 -->|defined in| 80ce950d_4c72_e7d9_21bb_a5c60524786c e9196f64_5130_591a_2468_ec6a5432629b["serialize_dt_field()"] a3bb3705_7383_2a9b_2bd8_7b9eb6335743 -->|calls| e9196f64_5130_591a_2468_ec6a5432629b 78cf9f6d_f562_f455_e0de_8806b95a89f1["isoformat()"] a3bb3705_7383_2a9b_2bd8_7b9eb6335743 -->|calls| 78cf9f6d_f562_f455_e0de_8806b95a89f1 1ac1bc37_1a47_e7e2_9156_ab0473094700["jsonable_encoder()"] a3bb3705_7383_2a9b_2bd8_7b9eb6335743 -->|calls| 1ac1bc37_1a47_e7e2_9156_ab0473094700 style a3bb3705_7383_2a9b_2bd8_7b9eb6335743 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
tests/test_jsonable_encoder.py lines 140–156
def test_encode_custom_json_encoders_model_pydanticv2():
from pydantic import field_serializer
class ModelWithCustomEncoder(BaseModel):
dt_field: datetime
@field_serializer("dt_field")
def serialize_dt_field(self, dt):
return dt.replace(microsecond=0, tzinfo=timezone.utc).isoformat()
class ModelWithCustomEncoderSubclass(ModelWithCustomEncoder):
pass
model = ModelWithCustomEncoder(dt_field=datetime(2019, 1, 1, 8))
assert jsonable_encoder(model) == {"dt_field": "2019-01-01T08:00:00+00:00"}
subclass_model = ModelWithCustomEncoderSubclass(dt_field=datetime(2019, 1, 1, 8))
assert jsonable_encoder(subclass_model) == {"dt_field": "2019-01-01T08:00:00+00:00"}
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does test_encode_custom_json_encoders_model_pydanticv2() do?
test_encode_custom_json_encoders_model_pydanticv2() is a function in the fastapi codebase, defined in tests/test_jsonable_encoder.py.
Where is test_encode_custom_json_encoders_model_pydanticv2() defined?
test_encode_custom_json_encoders_model_pydanticv2() is defined in tests/test_jsonable_encoder.py at line 140.
What does test_encode_custom_json_encoders_model_pydanticv2() call?
test_encode_custom_json_encoders_model_pydanticv2() calls 3 function(s): isoformat, jsonable_encoder, serialize_dt_field.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free