test_datetime_custom_encoder.py — fastapi Source File
Architecture documentation for test_datetime_custom_encoder.py, a python file in the fastapi codebase. 4 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR ba3bdf28_df52_2d09_627b_a8d890f2909e["test_datetime_custom_encoder.py"] e973e384_8276_b242_eb98_1c0b79a84e68["datetime"] ba3bdf28_df52_2d09_627b_a8d890f2909e --> e973e384_8276_b242_eb98_1c0b79a84e68 534f6e44_61b8_3c38_8b89_6934a6df9802["__init__.py"] ba3bdf28_df52_2d09_627b_a8d890f2909e --> 534f6e44_61b8_3c38_8b89_6934a6df9802 a7c04dee_ee23_5891_b185_47ff6bed036d["testclient.py"] ba3bdf28_df52_2d09_627b_a8d890f2909e --> a7c04dee_ee23_5891_b185_47ff6bed036d 6913fbd4_39df_d14b_44bb_522e99b65b90["pydantic"] ba3bdf28_df52_2d09_627b_a8d890f2909e --> 6913fbd4_39df_d14b_44bb_522e99b65b90 style ba3bdf28_df52_2d09_627b_a8d890f2909e fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
from datetime import datetime, timezone
from fastapi import FastAPI
from fastapi.testclient import TestClient
from pydantic import BaseModel
def test_pydanticv2():
from pydantic import field_serializer
class ModelWithDatetimeField(BaseModel):
dt_field: datetime
@field_serializer("dt_field")
def serialize_datetime(self, dt_field: datetime):
return dt_field.replace(microsecond=0, tzinfo=timezone.utc).isoformat()
app = FastAPI()
model = ModelWithDatetimeField(dt_field=datetime(2019, 1, 1, 8))
@app.get("/model", response_model=ModelWithDatetimeField)
def get_model():
return model
client = TestClient(app)
with client:
response = client.get("/model")
assert response.json() == {"dt_field": "2019-01-01T08:00:00+00:00"}
Domain
Subdomains
Functions
Classes
Dependencies
- __init__.py
- datetime
- pydantic
- testclient.py
Source
Frequently Asked Questions
What does test_datetime_custom_encoder.py do?
test_datetime_custom_encoder.py is a source file in the fastapi codebase, written in python. It belongs to the FastAPI domain, Responses subdomain.
What functions are defined in test_datetime_custom_encoder.py?
test_datetime_custom_encoder.py defines 1 function(s): test_pydanticv2.
What does test_datetime_custom_encoder.py depend on?
test_datetime_custom_encoder.py imports 4 module(s): __init__.py, datetime, pydantic, testclient.py.
Where is test_datetime_custom_encoder.py in the architecture?
test_datetime_custom_encoder.py is located at tests/test_datetime_custom_encoder.py (domain: FastAPI, subdomain: Responses, directory: tests).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free