test_union_response_different_types() — anthropic-sdk-python Function Reference
Architecture documentation for the test_union_response_different_types() function in test_client.py from the anthropic-sdk-python codebase.
Entity Profile
Dependency Diagram
graph TD 34879ca3_3e2e_7ec0_ef82_b3fea491ba05["test_union_response_different_types()"] 8e4a3d47_aab6_a544_c052_b462b305ae9f["TestAnthropic"] 34879ca3_3e2e_7ec0_ef82_b3fea491ba05 -->|defined in| 8e4a3d47_aab6_a544_c052_b462b305ae9f 790f80f8_e045_0ab9_f51d_c169492895ba["test_union_response_different_types()"] 790f80f8_e045_0ab9_f51d_c169492895ba -->|calls| 34879ca3_3e2e_7ec0_ef82_b3fea491ba05 790f80f8_e045_0ab9_f51d_c169492895ba["test_union_response_different_types()"] 34879ca3_3e2e_7ec0_ef82_b3fea491ba05 -->|calls| 790f80f8_e045_0ab9_f51d_c169492895ba style 34879ca3_3e2e_7ec0_ef82_b3fea491ba05 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
tests/test_client.py lines 645–664
def test_union_response_different_types(self, respx_mock: MockRouter, client: Anthropic) -> None:
"""Union of objects with the same field name using a different type"""
class Model1(BaseModel):
foo: int
class Model2(BaseModel):
foo: str
respx_mock.get("/foo").mock(return_value=httpx.Response(200, json={"foo": "bar"}))
response = client.get("/foo", cast_to=cast(Any, Union[Model1, Model2]))
assert isinstance(response, Model2)
assert response.foo == "bar"
respx_mock.get("/foo").mock(return_value=httpx.Response(200, json={"foo": 1}))
response = client.get("/foo", cast_to=cast(Any, Union[Model1, Model2]))
assert isinstance(response, Model1)
assert response.foo == 1
Domain
Subdomains
Defined In
Called By
Source
Frequently Asked Questions
What does test_union_response_different_types() do?
test_union_response_different_types() is a function in the anthropic-sdk-python codebase, defined in tests/test_client.py.
Where is test_union_response_different_types() defined?
test_union_response_different_types() is defined in tests/test_client.py at line 645.
What does test_union_response_different_types() call?
test_union_response_different_types() calls 1 function(s): test_union_response_different_types.
What calls test_union_response_different_types()?
test_union_response_different_types() is called by 1 function(s): test_union_response_different_types.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free