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

test_http_client_timeout_option() — anthropic-sdk-python Function Reference

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

Function python AnthropicClient AsyncAPI calls 1 called by 1

Entity Profile

Dependency Diagram

graph TD
  c5c4685e_c879_bd1a_2a40_10f8966d502d["test_http_client_timeout_option()"]
  d53b6c34_1743_a045_4be1_3554ab153964["TestAnthropic"]
  c5c4685e_c879_bd1a_2a40_10f8966d502d -->|defined in| d53b6c34_1743_a045_4be1_3554ab153964
  8aa77014_e9b9_ece4_2363_ececdcc9df4e["test_http_client_timeout_option()"]
  8aa77014_e9b9_ece4_2363_ececdcc9df4e -->|calls| c5c4685e_c879_bd1a_2a40_10f8966d502d
  8aa77014_e9b9_ece4_2363_ececdcc9df4e["test_http_client_timeout_option()"]
  c5c4685e_c879_bd1a_2a40_10f8966d502d -->|calls| 8aa77014_e9b9_ece4_2363_ececdcc9df4e
  style c5c4685e_c879_bd1a_2a40_10f8966d502d fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

tests/test_client.py lines 332–367

    def test_http_client_timeout_option(self) -> None:
        # custom timeout given to the httpx client should be used
        with httpx.Client(timeout=None) as http_client:
            client = Anthropic(
                base_url=base_url, api_key=api_key, _strict_response_validation=True, http_client=http_client
            )

            request = client._build_request(FinalRequestOptions(method="get", url="/foo"))
            timeout = httpx.Timeout(**request.extensions["timeout"])  # type: ignore
            assert timeout == httpx.Timeout(None)

            client.close()

        # no timeout given to the httpx client should not use the httpx default
        with httpx.Client() as http_client:
            client = Anthropic(
                base_url=base_url, api_key=api_key, _strict_response_validation=True, http_client=http_client
            )

            request = client._build_request(FinalRequestOptions(method="get", url="/foo"))
            timeout = httpx.Timeout(**request.extensions["timeout"])  # type: ignore
            assert timeout == DEFAULT_TIMEOUT

            client.close()

        # explicitly passing the default timeout currently results in it being ignored
        with httpx.Client(timeout=HTTPX_DEFAULT_TIMEOUT) as http_client:
            client = Anthropic(
                base_url=base_url, api_key=api_key, _strict_response_validation=True, http_client=http_client
            )

            request = client._build_request(FinalRequestOptions(method="get", url="/foo"))
            timeout = httpx.Timeout(**request.extensions["timeout"])  # type: ignore
            assert timeout == DEFAULT_TIMEOUT  # our default

            client.close()

Subdomains

Frequently Asked Questions

What does test_http_client_timeout_option() do?
test_http_client_timeout_option() is a function in the anthropic-sdk-python codebase, defined in tests/test_client.py.
Where is test_http_client_timeout_option() defined?
test_http_client_timeout_option() is defined in tests/test_client.py at line 332.
What does test_http_client_timeout_option() call?
test_http_client_timeout_option() calls 1 function(s): test_http_client_timeout_option.
What calls test_http_client_timeout_option()?
test_http_client_timeout_option() is called by 1 function(s): test_http_client_timeout_option.

Analyze Your Own Codebase

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

Try Supermodel Free