client_fixture() — fastapi Function Reference
Architecture documentation for the client_fixture() function in test_union_body_discriminator_annotated.py from the fastapi codebase.
Entity Profile
Dependency Diagram
graph TD 9d6526c8_0d0c_a21d_d732_884e55210d8e["client_fixture()"] 2085b234_c53e_638c_3dcf_8d81fbaa1f3d["test_union_body_discriminator_annotated.py"] 9d6526c8_0d0c_a21d_d732_884e55210d8e -->|defined in| 2085b234_c53e_638c_3dcf_8d81fbaa1f3d style 9d6526c8_0d0c_a21d_d732_884e55210d8e fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
tests/test_union_body_discriminator_annotated.py lines 13–45
def client_fixture() -> TestClient:
from fastapi import Body
from pydantic import Discriminator, Tag
class Cat(BaseModel):
pet_type: str = "cat"
meows: int
class Dog(BaseModel):
pet_type: str = "dog"
barks: float
def get_pet_type(v):
assert isinstance(v, dict)
return v.get("pet_type", "")
Pet = Annotated[
Union[Annotated[Cat, Tag("cat")], Annotated[Dog, Tag("dog")]],
Discriminator(get_pet_type),
]
app = FastAPI()
@app.post("/pet/assignment")
async def create_pet_assignment(pet: Pet = Body()):
return pet
@app.post("/pet/annotated")
async def create_pet_annotated(pet: Annotated[Pet, Body()]):
return pet
client = TestClient(app)
return client
Domain
Subdomains
Source
Frequently Asked Questions
What does client_fixture() do?
client_fixture() is a function in the fastapi codebase, defined in tests/test_union_body_discriminator_annotated.py.
Where is client_fixture() defined?
client_fixture() is defined in tests/test_union_body_discriminator_annotated.py at line 13.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free