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
  8c5d2767_1b9e_bda8_211a_5367f8221ed1["test_received_text_for_expected_json()"]
  9bf4cfe0_e3b0_70de_25ac_2113c8918900["TestAsyncAnthropic"]
  8c5d2767_1b9e_bda8_211a_5367f8221ed1 -->|defined in| 9bf4cfe0_e3b0_70de_25ac_2113c8918900
  b5be6be0_c319_909f_664a_df0d0132596c["test_received_text_for_expected_json()"]
  b5be6be0_c319_909f_664a_df0d0132596c -->|calls| 8c5d2767_1b9e_bda8_211a_5367f8221ed1
  b5be6be0_c319_909f_664a_df0d0132596c["test_received_text_for_expected_json()"]
  8c5d2767_1b9e_bda8_211a_5367f8221ed1 -->|calls| b5be6be0_c319_909f_664a_df0d0132596c
  style 8c5d2767_1b9e_bda8_211a_5367f8221ed1 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

tests/test_client.py lines 1816–1833

    async 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 = AsyncAnthropic(base_url=base_url, api_key=api_key, _strict_response_validation=True)

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

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

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

        await strict_client.close()
        await 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 1816.
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