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

test_received_text_for_expected_json() — anthropic-sdk-python Function Reference

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

Function python AnthropicClient SyncAPI calls 1 called by 1

Entity Profile

Dependency Diagram

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

Relationship Graph

Source Code

tests/test_client.py lines 821–838

    def test_received_text_for_expected_json(self, respx_mock: MockRouter) -> None:
        class Model(BaseModel):
            name: str

        respx_mock.get("/foo").mock(return_value=httpx.Response(200, text="my-custom-format"))

        strict_client = Anthropic(base_url=base_url, api_key=api_key, _strict_response_validation=True)

        with pytest.raises(APIResponseValidationError):
            strict_client.get("/foo", cast_to=Model)

        non_strict_client = Anthropic(base_url=base_url, api_key=api_key, _strict_response_validation=False)

        response = non_strict_client.get("/foo", cast_to=Model)
        assert isinstance(response, str)  # type: ignore[unreachable]

        strict_client.close()
        non_strict_client.close()

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free