test_tool_use() — anthropic-sdk-python Function Reference
Architecture documentation for the test_tool_use() function in test_messages.py from the anthropic-sdk-python codebase.
Entity Profile
Dependency Diagram
graph TD 5ebbac27_1dab_4a90_da3e_df522b071a97["test_tool_use()"] 58e51afa_63b8_b81d_14f4_b90e7b76512c["TestAsyncMessages"] 5ebbac27_1dab_4a90_da3e_df522b071a97 -->|defined in| 58e51afa_63b8_b81d_14f4_b90e7b76512c ee7a56e8_2e83_4351_5d7c_8d9b27fba3d2["test_tool_use()"] ee7a56e8_2e83_4351_5d7c_8d9b27fba3d2 -->|calls| 5ebbac27_1dab_4a90_da3e_df522b071a97 ee7a56e8_2e83_4351_5d7c_8d9b27fba3d2["test_tool_use()"] 5ebbac27_1dab_4a90_da3e_df522b071a97 -->|calls| ee7a56e8_2e83_4351_5d7c_8d9b27fba3d2 cb02636d_b74b_7724_2966_191b6bc19c0f["to_async_iter()"] 5ebbac27_1dab_4a90_da3e_df522b071a97 -->|calls| cb02636d_b74b_7724_2966_191b6bc19c0f d1b2725b_0ccb_90ce_868b_51db8c397a89["get_response()"] 5ebbac27_1dab_4a90_da3e_df522b071a97 -->|calls| d1b2725b_0ccb_90ce_868b_51db8c397a89 af77ac1b_27fe_6c86_65c8_5db8fbaa22dc["assert_tool_use_response()"] 5ebbac27_1dab_4a90_da3e_df522b071a97 -->|calls| af77ac1b_27fe_6c86_65c8_5db8fbaa22dc style 5ebbac27_1dab_4a90_da3e_df522b071a97 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
tests/lib/streaming/test_messages.py lines 253–271
async def test_tool_use(self, respx_mock: MockRouter) -> None:
respx_mock.post("/v1/messages").mock(
return_value=httpx.Response(200, content=to_async_iter(get_response("tool_use_response.txt")))
)
async with async_client.messages.stream(
max_tokens=1024,
messages=[
{
"role": "user",
"content": "Say hello there!",
}
],
model="claude-sonnet-4-20250514",
) as stream:
with pytest.warns(DeprecationWarning):
assert isinstance(cast(Any, stream), AsyncStream)
assert_tool_use_response([event async for event in stream], await stream.get_final_message())
Domain
Subdomains
Defined In
Called By
Source
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_messages.py.
Where is test_tool_use() defined?
test_tool_use() is defined in tests/lib/streaming/test_messages.py at line 253.
What does test_tool_use() call?
test_tool_use() calls 4 function(s): assert_tool_use_response, get_response, test_tool_use, to_async_iter.
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