test_propagates_pydantic2_model_config() — fastapi Function Reference
Architecture documentation for the test_propagates_pydantic2_model_config() function in test_compat.py from the fastapi codebase.
Entity Profile
Dependency Diagram
graph TD b9b927bb_06fb_ce23_18d4_d959031c8e32["test_propagates_pydantic2_model_config()"] d8f09690_317a_a71d_db2f_7a9171e4e6fd["test_compat.py"] b9b927bb_06fb_ce23_18d4_d959031c8e32 -->|defined in| d8f09690_317a_a71d_db2f_7a9171e4e6fd style b9b927bb_06fb_ce23_18d4_d959031c8e32 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
tests/test_compat.py lines 43–84
def test_propagates_pydantic2_model_config():
app = FastAPI()
class Missing:
def __bool__(self):
return False
class EmbeddedModel(BaseModel):
model_config = ConfigDict(arbitrary_types_allowed=True)
value: Union[str, Missing] = Missing()
class Model(BaseModel):
model_config = ConfigDict(
arbitrary_types_allowed=True,
)
value: Union[str, Missing] = Missing()
embedded_model: EmbeddedModel = EmbeddedModel()
@app.post("/")
def foo(req: Model) -> dict[str, Union[str, None]]:
return {
"value": req.value or None,
"embedded_value": req.embedded_model.value or None,
}
client = TestClient(app)
response = client.post("/", json={})
assert response.status_code == 200, response.text
assert response.json() == {
"value": None,
"embedded_value": None,
}
response2 = client.post(
"/", json={"value": "foo", "embedded_model": {"value": "bar"}}
)
assert response2.status_code == 200, response2.text
assert response2.json() == {
"value": "foo",
"embedded_value": "bar",
}
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does test_propagates_pydantic2_model_config() do?
test_propagates_pydantic2_model_config() is a function in the fastapi codebase, defined in tests/test_compat.py.
Where is test_propagates_pydantic2_model_config() defined?
test_propagates_pydantic2_model_config() is defined in tests/test_compat.py at line 43.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free