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.

Function python AnthropicClient AsyncAPI calls 1 called by 1

Entity Profile

Dependency Diagram

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

Relationship Graph

Source Code

tests/test_client.py lines 160–193

    def test_copy_default_headers(self) -> None:
        client = Anthropic(
            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"})
        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 160.
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