test_union_of_dict() — anthropic-sdk-python Function Reference
Architecture documentation for the test_union_of_dict() function in test_models.py from the anthropic-sdk-python codebase.
Entity Profile
Dependency Diagram
graph TD d181aba7_5f29_6a20_8d8b_8e2a49d359b9["test_union_of_dict()"] 7872e60b_4210_5600_119f_c5d08c52091e["test_models.py"] d181aba7_5f29_6a20_8d8b_8e2a49d359b9 -->|defined in| 7872e60b_4210_5600_119f_c5d08c52091e style d181aba7_5f29_6a20_8d8b_8e2a49d359b9 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
tests/test_models.py lines 405–420
def test_union_of_dict() -> None:
class SubModel1(BaseModel):
name: str
class SubModel2(BaseModel):
foo: str
class Model(BaseModel):
data: Union[Dict[str, SubModel1], Dict[str, SubModel2]]
m = Model.construct(data={"hello": {"name": "there"}, "foo": {"foo": "bar"}})
assert len(list(m.data.keys())) == 2
assert isinstance(m.data["hello"], SubModel1)
assert m.data["hello"].name == "there"
assert isinstance(m.data["foo"], SubModel1)
assert cast(Any, m.data["foo"]).foo == "bar"
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does test_union_of_dict() do?
test_union_of_dict() is a function in the anthropic-sdk-python codebase, defined in tests/test_models.py.
Where is test_union_of_dict() defined?
test_union_of_dict() is defined in tests/test_models.py at line 405.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free