Home / Function/ test_nested_union_of_models() — anthropic-sdk-python Function Reference

test_nested_union_of_models() — anthropic-sdk-python Function Reference

Architecture documentation for the test_nested_union_of_models() function in test_models.py from the anthropic-sdk-python codebase.

Entity Profile

Dependency Diagram

graph TD
  0aec19cb_0a70_e05f_b54c_85c040be6457["test_nested_union_of_models()"]
  7872e60b_4210_5600_119f_c5d08c52091e["test_models.py"]
  0aec19cb_0a70_e05f_b54c_85c040be6457 -->|defined in| 7872e60b_4210_5600_119f_c5d08c52091e
  style 0aec19cb_0a70_e05f_b54c_85c040be6457 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

tests/test_models.py lines 222–234

def test_nested_union_of_models() -> None:
    class Submodel1(BaseModel):
        bar: bool

    class Submodel2(BaseModel):
        thing: str

    class Model(BaseModel):
        foo: Union[Submodel1, Submodel2]

    m = Model.construct(foo={"thing": "hello"})
    assert isinstance(m.foo, Submodel2)
    assert m.foo.thing == "hello"

Subdomains

Frequently Asked Questions

What does test_nested_union_of_models() do?
test_nested_union_of_models() is a function in the anthropic-sdk-python codebase, defined in tests/test_models.py.
Where is test_nested_union_of_models() defined?
test_nested_union_of_models() is defined in tests/test_models.py at line 222.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free