test_response.py — anthropic-sdk-python Source File
Architecture documentation for test_response.py, a python file in the anthropic-sdk-python codebase. 10 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR d84478fe_6b5f_cefd_a948_48255cf7924b["test_response.py"] 28b0c811_20f6_fc4a_4b48_7fb9e87bf7e5["json"] d84478fe_6b5f_cefd_a948_48255cf7924b --> 28b0c811_20f6_fc4a_4b48_7fb9e87bf7e5 89ddcdd7_3ae1_4c7b_41bb_9f1e25f16875["typing"] d84478fe_6b5f_cefd_a948_48255cf7924b --> 89ddcdd7_3ae1_4c7b_41bb_9f1e25f16875 37c05070_ca59_d596_7250_de9d1939227f["typing_extensions"] d84478fe_6b5f_cefd_a948_48255cf7924b --> 37c05070_ca59_d596_7250_de9d1939227f 9c26e8a9_1ad2_1174_876a_1fc500ce0eaf["httpx"] d84478fe_6b5f_cefd_a948_48255cf7924b --> 9c26e8a9_1ad2_1174_876a_1fc500ce0eaf cde8421b_93c7_41e4_d69d_2a3f1bade2f2["pytest"] d84478fe_6b5f_cefd_a948_48255cf7924b --> cde8421b_93c7_41e4_d69d_2a3f1bade2f2 21de8837_7dae_989e_fdbb_1415c0770d90["pydantic"] d84478fe_6b5f_cefd_a948_48255cf7924b --> 21de8837_7dae_989e_fdbb_1415c0770d90 d10c5377_2939_0f0b_cc44_8759393f2853["anthropic"] d84478fe_6b5f_cefd_a948_48255cf7924b --> d10c5377_2939_0f0b_cc44_8759393f2853 ea606e9d_0e18_6912_4ea7_7d29a732350b["anthropic._response"] d84478fe_6b5f_cefd_a948_48255cf7924b --> ea606e9d_0e18_6912_4ea7_7d29a732350b 4576f658_f93f_2a77_9ff8_4875c797aab6["anthropic._streaming"] d84478fe_6b5f_cefd_a948_48255cf7924b --> 4576f658_f93f_2a77_9ff8_4875c797aab6 9c2d34b7_fa28_dac8_c499_f65e981c87d8["anthropic._base_client"] d84478fe_6b5f_cefd_a948_48255cf7924b --> 9c2d34b7_fa28_dac8_c499_f65e981c87d8 style d84478fe_6b5f_cefd_a948_48255cf7924b fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import json
from typing import Any, List, Union, cast
from typing_extensions import Annotated
import httpx
import pytest
import pydantic
from anthropic import Anthropic, BaseModel, AsyncAnthropic
from anthropic._response import (
APIResponse,
BaseAPIResponse,
AsyncAPIResponse,
BinaryAPIResponse,
AsyncBinaryAPIResponse,
extract_response_type,
)
from anthropic._streaming import Stream
from anthropic._base_client import FinalRequestOptions
class ConcreteBaseAPIResponse(APIResponse[bytes]): ...
class ConcreteAPIResponse(APIResponse[List[str]]): ...
class ConcreteAsyncAPIResponse(APIResponse[httpx.Response]): ...
def test_extract_response_type_direct_classes() -> None:
assert extract_response_type(BaseAPIResponse[str]) == str
assert extract_response_type(APIResponse[str]) == str
assert extract_response_type(AsyncAPIResponse[str]) == str
def test_extract_response_type_direct_class_missing_type_arg() -> None:
with pytest.raises(
RuntimeError,
match="Expected type <class 'anthropic._response.AsyncAPIResponse'> to have a type argument at index 0 but it did not",
):
extract_response_type(AsyncAPIResponse)
def test_extract_response_type_concrete_subclasses() -> None:
assert extract_response_type(ConcreteBaseAPIResponse) == bytes
assert extract_response_type(ConcreteAPIResponse) == List[str]
assert extract_response_type(ConcreteAsyncAPIResponse) == httpx.Response
def test_extract_response_type_binary_response() -> None:
assert extract_response_type(BinaryAPIResponse) == bytes
assert extract_response_type(AsyncBinaryAPIResponse) == bytes
class PydanticModel(pydantic.BaseModel): ...
def test_response_parse_mismatched_basemodel(client: Anthropic) -> None:
response = APIResponse(
// ... (259 more lines)
Domain
Subdomains
Functions
- test_async_response_basemodel_request_id()
- test_async_response_parse_annotated_type()
- test_async_response_parse_bool()
- test_async_response_parse_custom_model()
- test_async_response_parse_custom_stream()
- test_async_response_parse_expect_model_union_non_json_content()
- test_async_response_parse_mismatched_basemodel()
- test_extract_response_type_binary_response()
- test_extract_response_type_concrete_subclasses()
- test_extract_response_type_direct_class_missing_type_arg()
- test_extract_response_type_direct_classes()
- test_response_basemodel_request_id()
- test_response_parse_annotated_type()
- test_response_parse_bool()
- test_response_parse_custom_model()
- test_response_parse_custom_stream()
- test_response_parse_expect_model_union_non_json_content()
- test_response_parse_mismatched_basemodel()
Classes
Dependencies
- anthropic
- anthropic._base_client
- anthropic._response
- anthropic._streaming
- httpx
- json
- pydantic
- pytest
- typing
- typing_extensions
Source
Frequently Asked Questions
What does test_response.py do?
test_response.py is a source file in the anthropic-sdk-python codebase, written in python. It belongs to the AnthropicClient domain, SyncAPI subdomain.
What functions are defined in test_response.py?
test_response.py defines 18 function(s): test_async_response_basemodel_request_id, test_async_response_parse_annotated_type, test_async_response_parse_bool, test_async_response_parse_custom_model, test_async_response_parse_custom_stream, test_async_response_parse_expect_model_union_non_json_content, test_async_response_parse_mismatched_basemodel, test_extract_response_type_binary_response, test_extract_response_type_concrete_subclasses, test_extract_response_type_direct_class_missing_type_arg, and 8 more.
What does test_response.py depend on?
test_response.py imports 10 module(s): anthropic, anthropic._base_client, anthropic._response, anthropic._streaming, httpx, json, pydantic, pytest, and 2 more.
Where is test_response.py in the architecture?
test_response.py is located at tests/test_response.py (domain: AnthropicClient, subdomain: SyncAPI, directory: tests).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free