Home / Class/ TestBatches Class — anthropic-sdk-python Architecture

TestBatches Class — anthropic-sdk-python Architecture

Architecture documentation for the TestBatches class in test_batches.py from the anthropic-sdk-python codebase.

Entity Profile

Dependency Diagram

graph TD
  9a832258_7f6b_3def_c68d_76dcd3360ad4["TestBatches"]
  3e107774_1462_d161_d688_0579282f7e10["MessageBatch"]
  9a832258_7f6b_3def_c68d_76dcd3360ad4 -->|extends| 3e107774_1462_d161_d688_0579282f7e10
  6f0c2763_2404_28c1_053f_f98121dd7d2a["DeletedMessageBatch"]
  9a832258_7f6b_3def_c68d_76dcd3360ad4 -->|extends| 6f0c2763_2404_28c1_053f_f98121dd7d2a
  dd332f9f_baa1_66e7_daf2_701c347cd3bf["test_batches.py"]
  9a832258_7f6b_3def_c68d_76dcd3360ad4 -->|defined in| dd332f9f_baa1_66e7_daf2_701c347cd3bf
  0837cdb1_d07a_6830_d4c9_57e8089e52b2["test_method_create()"]
  9a832258_7f6b_3def_c68d_76dcd3360ad4 -->|method| 0837cdb1_d07a_6830_d4c9_57e8089e52b2
  363f4b06_c81b_54c1_a6a6_54ea0dac8962["test_raw_response_create()"]
  9a832258_7f6b_3def_c68d_76dcd3360ad4 -->|method| 363f4b06_c81b_54c1_a6a6_54ea0dac8962
  0688c668_d463_758c_fc93_a6f813306e50["test_streaming_response_create()"]
  9a832258_7f6b_3def_c68d_76dcd3360ad4 -->|method| 0688c668_d463_758c_fc93_a6f813306e50
  142a8963_cba1_d8a3_1f98_75af2b5885d8["test_method_retrieve()"]
  9a832258_7f6b_3def_c68d_76dcd3360ad4 -->|method| 142a8963_cba1_d8a3_1f98_75af2b5885d8
  32dd800c_d404_47d8_f54f_3f1b9f98e404["test_raw_response_retrieve()"]
  9a832258_7f6b_3def_c68d_76dcd3360ad4 -->|method| 32dd800c_d404_47d8_f54f_3f1b9f98e404
  c073cd32_2b9f_28b4_1dea_e9cf1587c135["test_streaming_response_retrieve()"]
  9a832258_7f6b_3def_c68d_76dcd3360ad4 -->|method| c073cd32_2b9f_28b4_1dea_e9cf1587c135
  d8dcd6d6_ebce_6a3f_bfbc_1e6606b178c3["test_path_params_retrieve()"]
  9a832258_7f6b_3def_c68d_76dcd3360ad4 -->|method| d8dcd6d6_ebce_6a3f_bfbc_1e6606b178c3
  b5fa4b5e_d1dd_56a9_253b_a4a9ba2e55f1["test_method_list()"]
  9a832258_7f6b_3def_c68d_76dcd3360ad4 -->|method| b5fa4b5e_d1dd_56a9_253b_a4a9ba2e55f1
  47fdc710_05b5_5e65_4ab6_dfa566645563["test_method_list_with_all_params()"]
  9a832258_7f6b_3def_c68d_76dcd3360ad4 -->|method| 47fdc710_05b5_5e65_4ab6_dfa566645563
  3279a18c_1517_d451_8787_54e71c497a34["test_raw_response_list()"]
  9a832258_7f6b_3def_c68d_76dcd3360ad4 -->|method| 3279a18c_1517_d451_8787_54e71c497a34
  6506530d_6a22_b656_94cd_19108a91b47a["test_streaming_response_list()"]
  9a832258_7f6b_3def_c68d_76dcd3360ad4 -->|method| 6506530d_6a22_b656_94cd_19108a91b47a

Relationship Graph

Source Code

tests/api_resources/messages/test_batches.py lines 23–275

class TestBatches:
    parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"])

    @parametrize
    def test_method_create(self, client: Anthropic) -> None:
        batch = client.messages.batches.create(
            requests=[
                {
                    "custom_id": "my-custom-id-1",
                    "params": {
                        "max_tokens": 1024,
                        "messages": [
                            {
                                "content": "Hello, world",
                                "role": "user",
                            }
                        ],
                        "model": "claude-opus-4-6",
                    },
                }
            ],
        )
        assert_matches_type(MessageBatch, batch, path=["response"])

    @parametrize
    def test_raw_response_create(self, client: Anthropic) -> None:
        response = client.messages.batches.with_raw_response.create(
            requests=[
                {
                    "custom_id": "my-custom-id-1",
                    "params": {
                        "max_tokens": 1024,
                        "messages": [
                            {
                                "content": "Hello, world",
                                "role": "user",
                            }
                        ],
                        "model": "claude-opus-4-6",
                    },
                }
            ],
        )

        assert response.is_closed is True
        assert response.http_request.headers.get("X-Stainless-Lang") == "python"
        batch = response.parse()
        assert_matches_type(MessageBatch, batch, path=["response"])

    @parametrize
    def test_streaming_response_create(self, client: Anthropic) -> None:
        with client.messages.batches.with_streaming_response.create(
            requests=[
                {
                    "custom_id": "my-custom-id-1",
                    "params": {
                        "max_tokens": 1024,
                        "messages": [
                            {
                                "content": "Hello, world",
                                "role": "user",
                            }
                        ],
                        "model": "claude-opus-4-6",
                    },
                }
            ],
        ) as response:
            assert not response.is_closed
            assert response.http_request.headers.get("X-Stainless-Lang") == "python"

            batch = response.parse()
            assert_matches_type(MessageBatch, batch, path=["response"])

        assert cast(Any, response.is_closed) is True

    @parametrize
    def test_method_retrieve(self, client: Anthropic) -> None:
        batch = client.messages.batches.retrieve(
            "message_batch_id",
        )

Frequently Asked Questions

What is the TestBatches class?
TestBatches is a class in the anthropic-sdk-python codebase, defined in tests/api_resources/messages/test_batches.py.
Where is TestBatches defined?
TestBatches is defined in tests/api_resources/messages/test_batches.py at line 23.
What does TestBatches extend?
TestBatches extends MessageBatch, DeletedMessageBatch.

Analyze Your Own Codebase

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

Try Supermodel Free