test_context_manager() — anthropic-sdk-python Function Reference
Architecture documentation for the test_context_manager() function in test_beta_messages.py from the anthropic-sdk-python codebase.
Entity Profile
Dependency Diagram
graph TD d7d85fbf_ea7f_b02a_9f96_2044dd6ec764["test_context_manager()"] 3b785fa6_7fe8_27f9_a4b3_d1b931c9e188["TestAsyncMessages"] d7d85fbf_ea7f_b02a_9f96_2044dd6ec764 -->|defined in| 3b785fa6_7fe8_27f9_a4b3_d1b931c9e188 78655d86_e01f_f848_1839_a877c36f94a5["test_context_manager()"] 78655d86_e01f_f848_1839_a877c36f94a5 -->|calls| d7d85fbf_ea7f_b02a_9f96_2044dd6ec764 78655d86_e01f_f848_1839_a877c36f94a5["test_context_manager()"] d7d85fbf_ea7f_b02a_9f96_2044dd6ec764 -->|calls| 78655d86_e01f_f848_1839_a877c36f94a5 cb02636d_b74b_7724_2966_191b6bc19c0f["to_async_iter()"] d7d85fbf_ea7f_b02a_9f96_2044dd6ec764 -->|calls| cb02636d_b74b_7724_2966_191b6bc19c0f d1b2725b_0ccb_90ce_868b_51db8c397a89["get_response()"] d7d85fbf_ea7f_b02a_9f96_2044dd6ec764 -->|calls| d1b2725b_0ccb_90ce_868b_51db8c397a89 style d7d85fbf_ea7f_b02a_9f96_2044dd6ec764 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
tests/lib/streaming/test_beta_messages.py lines 291–309
async def test_context_manager(self, respx_mock: MockRouter) -> None:
respx_mock.post("/v1/messages").mock(
return_value=httpx.Response(200, content=to_async_iter(get_response("basic_response.txt")))
)
async with async_client.beta.messages.stream(
max_tokens=1024,
messages=[
{
"role": "user",
"content": "Say hello there!",
}
],
model="claude-3-opus-latest",
) as stream:
assert not stream.response.is_closed
# response should be closed even if the body isn't read
assert stream.response.is_closed
Domain
Subdomains
Defined In
Called By
Source
Frequently Asked Questions
What does test_context_manager() do?
test_context_manager() is a function in the anthropic-sdk-python codebase, defined in tests/lib/streaming/test_beta_messages.py.
Where is test_context_manager() defined?
test_context_manager() is defined in tests/lib/streaming/test_beta_messages.py at line 291.
What does test_context_manager() call?
test_context_manager() calls 3 function(s): get_response, test_context_manager, to_async_iter.
What calls test_context_manager()?
test_context_manager() is called by 1 function(s): test_context_manager.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free