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

test_copy_default_headers() — anthropic-sdk-python Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  4b2dc738_ca52_0d04_33d8_d56d8628eccd["test_copy_default_headers()"]
  9bf4cfe0_e3b0_70de_25ac_2113c8918900["TestAsyncAnthropic"]
  4b2dc738_ca52_0d04_33d8_d56d8628eccd -->|defined in| 9bf4cfe0_e3b0_70de_25ac_2113c8918900
  42713461_a08c_cbdb_7366_defcb18a80f1["test_copy_default_headers()"]
  42713461_a08c_cbdb_7366_defcb18a80f1 -->|calls| 4b2dc738_ca52_0d04_33d8_d56d8628eccd
  42713461_a08c_cbdb_7366_defcb18a80f1["test_copy_default_headers()"]
  4b2dc738_ca52_0d04_33d8_d56d8628eccd -->|calls| 42713461_a08c_cbdb_7366_defcb18a80f1
  style 4b2dc738_ca52_0d04_33d8_d56d8628eccd fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

tests/test_client.py lines 1138–1171

    async def test_copy_default_headers(self) -> None:
        client = AsyncAnthropic(
            base_url=base_url, api_key=api_key, _strict_response_validation=True, default_headers={"X-Foo": "bar"}
        )
        assert client.default_headers["X-Foo"] == "bar"

        # does not override the already given value when not specified
        copied = client.copy()
        assert copied.default_headers["X-Foo"] == "bar"

        # merges already given headers
        copied = client.copy(default_headers={"X-Bar": "stainless"})
        assert copied.default_headers["X-Foo"] == "bar"
        assert copied.default_headers["X-Bar"] == "stainless"

        # uses new values for any already given headers
        copied = client.copy(default_headers={"X-Foo": "stainless"})
        assert copied.default_headers["X-Foo"] == "stainless"

        # set_default_headers

        # completely overrides already set values
        copied = client.copy(set_default_headers={})
        assert copied.default_headers.get("X-Foo") is None

        copied = client.copy(set_default_headers={"X-Bar": "Robert"})
        assert copied.default_headers["X-Bar"] == "Robert"

        with pytest.raises(
            ValueError,
            match="`default_headers` and `set_default_headers` arguments are mutually exclusive",
        ):
            client.copy(set_default_headers={}, default_headers={"X-Foo": "Bar"})
        await client.close()

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free