test_discriminated_union_case() — anthropic-sdk-python Function Reference
Architecture documentation for the test_discriminated_union_case() function in test_models.py from the anthropic-sdk-python codebase.
Entity Profile
Dependency Diagram
graph TD 2a1984ef_85f4_c4ed_bb1c_154449469a1b["test_discriminated_union_case()"] 7872e60b_4210_5600_119f_c5d08c52091e["test_models.py"] 2a1984ef_85f4_c4ed_bb1c_154449469a1b -->|defined in| 7872e60b_4210_5600_119f_c5d08c52091e style 2a1984ef_85f4_c4ed_bb1c_154449469a1b fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
tests/test_models.py lines 862–891
def test_discriminated_union_case() -> None:
class A(BaseModel):
type: Literal["a"]
data: bool
class B(BaseModel):
type: Literal["b"]
data: List[Union[A, object]]
class ModelA(BaseModel):
type: Literal["modelA"]
data: int
class ModelB(BaseModel):
type: Literal["modelB"]
required: str
data: Union[A, B]
# when constructing ModelA | ModelB, value data doesn't match ModelB exactly - missing `required`
m = construct_type(
value={"type": "modelB", "data": {"type": "a", "data": True}},
type_=cast(Any, Annotated[Union[ModelA, ModelB], PropertyInfo(discriminator="type")]),
)
assert isinstance(m, ModelB)
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does test_discriminated_union_case() do?
test_discriminated_union_case() is a function in the anthropic-sdk-python codebase, defined in tests/test_models.py.
Where is test_discriminated_union_case() defined?
test_discriminated_union_case() is defined in tests/test_models.py at line 862.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free