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
  dedb6ce2_d358_dcd0_d5bd_478229c3afd9["test_method_results()"]
  4fd27e2e_c95e_1ba6_4183_6ea591b00faa["TestBatches"]
  dedb6ce2_d358_dcd0_d5bd_478229c3afd9 -->|defined in| 4fd27e2e_c95e_1ba6_4183_6ea591b00faa
  989e171c_7cc6_12e9_fa7c_a8d9e28acdf5["test_method_results()"]
  989e171c_7cc6_12e9_fa7c_a8d9e28acdf5 -->|calls| dedb6ce2_d358_dcd0_d5bd_478229c3afd9
  989e171c_7cc6_12e9_fa7c_a8d9e28acdf5["test_method_results()"]
  dedb6ce2_d358_dcd0_d5bd_478229c3afd9 -->|calls| 989e171c_7cc6_12e9_fa7c_a8d9e28acdf5
  style dedb6ce2_d358_dcd0_d5bd_478229c3afd9 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

tests/api_resources/beta/messages/test_batches.py lines 416–443

    def test_method_results(self, client: Anthropic, respx_mock: MockRouter) -> None:
        respx_mock.get("/v1/messages/batches/message_batch_id?beta=true").mock(
            return_value=httpx.Response(
                200, json={"results_url": "/v1/messages/batches/message_batch_id/results?beta=true"}
            )
        )
        respx_mock.get("/v1/messages/batches/message_batch_id/results?beta=true").mock(
            return_value=httpx.Response(
                200, content="\n".join([json.dumps({"foo": "bar"}), json.dumps({"bar": "baz"})])
            )
        )
        results = 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 = 0
        for i, result in enumerate(results):
            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/beta/messages/test_batches.py.
Where is test_method_results() defined?
test_method_results() is defined in tests/api_resources/beta/messages/test_batches.py at line 416.
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