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

test_method_results() — anthropic-sdk-python Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  43ea5a5e_b2e5_67da_4286_d9f4972d1a36["test_method_results()"]
  3599ed31_8a6e_9753_ec3c_978d9ca4f1b5["TestAsyncBatches"]
  43ea5a5e_b2e5_67da_4286_d9f4972d1a36 -->|defined in| 3599ed31_8a6e_9753_ec3c_978d9ca4f1b5
  3dbd2517_4f0c_ecd3_73d4_49d97bda88ed["test_method_results()"]
  3dbd2517_4f0c_ecd3_73d4_49d97bda88ed -->|calls| 43ea5a5e_b2e5_67da_4286_d9f4972d1a36
  3dbd2517_4f0c_ecd3_73d4_49d97bda88ed["test_method_results()"]
  43ea5a5e_b2e5_67da_4286_d9f4972d1a36 -->|calls| 3dbd2517_4f0c_ecd3_73d4_49d97bda88ed
  style 43ea5a5e_b2e5_67da_4286_d9f4972d1a36 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

tests/api_resources/messages/test_batches.py lines 506–532

    async def test_method_results(self, async_client: AsyncAnthropic, respx_mock: MockRouter) -> None:
        respx_mock.get("/v1/messages/batches/message_batch_id").mock(
            return_value=httpx.Response(200, json={"results_url": "/v1/messages/batches/message_batch_id/results"})
        )
        respx_mock.get("/v1/messages/batches/message_batch_id/results").mock(
            return_value=httpx.Response(
                200, content="\n".join([json.dumps({"foo": "bar"}), json.dumps({"bar": "baz"})])
            )
        )
        results = await async_client.beta.messages.batches.results(
            message_batch_id="message_batch_id",
        )
        assert results.http_response is not None
        assert not results.http_response.is_stream_consumed

        i = -1
        async for result in results:
            i += 1
            if i == 0:
                assert result.to_dict() == {"foo": "bar"}
            elif i == 1:
                assert result.to_dict() == {"bar": "baz"}
            else:
                raise RuntimeError(f"iterated too many times, expected 2 times but got {i + 1}")

        assert i == 1
        assert results.http_response.is_stream_consumed

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free