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

test_tool_use() — anthropic-sdk-python Function Reference

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

Function python AnthropicClient SyncAPI calls 3 called by 1

Entity Profile

Dependency Diagram

graph TD
  8f450ef4_3bea_5a50_6741_63552939eb9f["test_tool_use()"]
  9bc201ea_a885_b5a7_1802_da159bef751a["TestSyncMessages"]
  8f450ef4_3bea_5a50_6741_63552939eb9f -->|defined in| 9bc201ea_a885_b5a7_1802_da159bef751a
  2d02c760_5abf_bf03_495b_f7d4b3fe39ab["test_tool_use()"]
  2d02c760_5abf_bf03_495b_f7d4b3fe39ab -->|calls| 8f450ef4_3bea_5a50_6741_63552939eb9f
  2d02c760_5abf_bf03_495b_f7d4b3fe39ab["test_tool_use()"]
  8f450ef4_3bea_5a50_6741_63552939eb9f -->|calls| 2d02c760_5abf_bf03_495b_f7d4b3fe39ab
  d1b2725b_0ccb_90ce_868b_51db8c397a89["get_response()"]
  8f450ef4_3bea_5a50_6741_63552939eb9f -->|calls| d1b2725b_0ccb_90ce_868b_51db8c397a89
  59d20233_d69f_b950_5ea4_1ee77ec38630["assert_tool_use_response()"]
  8f450ef4_3bea_5a50_6741_63552939eb9f -->|calls| 59d20233_d69f_b950_5ea4_1ee77ec38630
  style 8f450ef4_3bea_5a50_6741_63552939eb9f fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

tests/lib/streaming/test_beta_messages.py lines 210–227

    def test_tool_use(self, respx_mock: MockRouter) -> None:
        respx_mock.post("/v1/messages").mock(
            return_value=httpx.Response(200, content=get_response("tool_use_response.txt"))
        )

        with sync_client.beta.messages.stream(
            max_tokens=1024,
            messages=[
                {
                    "role": "user",
                    "content": "Say hello there!",
                }
            ],
            model="claude-sonnet-4-20250514",
        ) as stream:
            assert isinstance(cast(Any, stream), BetaMessageStream)

            assert_tool_use_response([event for event in stream], stream.get_final_message())

Subdomains

Called By

Frequently Asked Questions

What does test_tool_use() do?
test_tool_use() is a function in the anthropic-sdk-python codebase, defined in tests/lib/streaming/test_beta_messages.py.
Where is test_tool_use() defined?
test_tool_use() is defined in tests/lib/streaming/test_beta_messages.py at line 210.
What does test_tool_use() call?
test_tool_use() calls 3 function(s): assert_tool_use_response, get_response, test_tool_use.
What calls test_tool_use()?
test_tool_use() is called by 1 function(s): test_tool_use.

Analyze Your Own Codebase

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

Try Supermodel Free