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

test_validate_headers() — anthropic-sdk-python Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  90429b2b_700c_e136_aa60_7fc28ff6c2ff["test_validate_headers()"]
  d53b6c34_1743_a045_4be1_3554ab153964["TestAnthropic"]
  90429b2b_700c_e136_aa60_7fc28ff6c2ff -->|defined in| d53b6c34_1743_a045_4be1_3554ab153964
  4f5b95ea_36c4_7e43_da1d_3db4bc721964["test_validate_headers()"]
  4f5b95ea_36c4_7e43_da1d_3db4bc721964 -->|calls| 90429b2b_700c_e136_aa60_7fc28ff6c2ff
  4f5b95ea_36c4_7e43_da1d_3db4bc721964["test_validate_headers()"]
  90429b2b_700c_e136_aa60_7fc28ff6c2ff -->|calls| 4f5b95ea_36c4_7e43_da1d_3db4bc721964
  ae802d41_8406_bfb9_2e71_e38e830a98da["update_env()"]
  90429b2b_700c_e136_aa60_7fc28ff6c2ff -->|calls| ae802d41_8406_bfb9_2e71_e38e830a98da
  style 90429b2b_700c_e136_aa60_7fc28ff6c2ff fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

tests/test_client.py lines 403–418

    def test_validate_headers(self) -> None:
        client = Anthropic(base_url=base_url, api_key=api_key, _strict_response_validation=True)
        request = client._build_request(FinalRequestOptions(method="get", url="/foo"))
        assert request.headers.get("X-Api-Key") == api_key

        with update_env(**{"ANTHROPIC_API_KEY": Omit()}):
            client2 = Anthropic(base_url=base_url, api_key=None, _strict_response_validation=True)

        with pytest.raises(
            TypeError,
            match="Could not resolve authentication method. Expected either api_key or auth_token to be set. Or for one of the `X-Api-Key` or `Authorization` headers to be explicitly omitted",
        ):
            client2._build_request(FinalRequestOptions(method="get", url="/foo"))

        request2 = client2._build_request(FinalRequestOptions(method="get", url="/foo", headers={"X-Api-Key": Omit()}))
        assert request2.headers.get("X-Api-Key") is None

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free