test_dict_of_union() — anthropic-sdk-python Function Reference
Architecture documentation for the test_dict_of_union() function in test_models.py from the anthropic-sdk-python codebase.
Entity Profile
Dependency Diagram
graph TD 8427d132_9e95_09d6_2dfd_459aa9845b19["test_dict_of_union()"] 7872e60b_4210_5600_119f_c5d08c52091e["test_models.py"] 8427d132_9e95_09d6_2dfd_459aa9845b19 -->|defined in| 7872e60b_4210_5600_119f_c5d08c52091e style 8427d132_9e95_09d6_2dfd_459aa9845b19 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
tests/test_models.py lines 361–378
def test_dict_of_union() -> None:
class SubModel1(BaseModel):
name: str
class SubModel2(BaseModel):
foo: str
class Model(BaseModel):
data: Dict[str, Union[SubModel1, 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"], SubModel2)
assert m.data["foo"].foo == "bar"
# TODO: test mismatched type
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does test_dict_of_union() do?
test_dict_of_union() is a function in the anthropic-sdk-python codebase, defined in tests/test_models.py.
Where is test_dict_of_union() defined?
test_dict_of_union() is defined in tests/test_models.py at line 361.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free