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

test_messages_retries() — anthropic-sdk-python Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  269e4a15_82bc_c375_ad31_76ba68a862e7["test_messages_retries()"]
  ba53edc6_e72a_dfe0_42d5_c2a06c57d6a1["test_bedrock.py"]
  269e4a15_82bc_c375_ad31_76ba68a862e7 -->|defined in| ba53edc6_e72a_dfe0_42d5_c2a06c57d6a1
  style 269e4a15_82bc_c375_ad31_76ba68a862e7 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

tests/lib/test_bedrock.py lines 66–96

def test_messages_retries(respx_mock: MockRouter) -> None:
    respx_mock.post(re.compile(r"https://bedrock-runtime\.us-east-1\.amazonaws\.com/model/.*/invoke")).mock(
        side_effect=[
            httpx.Response(500, json={"error": "server error"}, headers={"retry-after-ms": "10"}),
            httpx.Response(200, json={"foo": "bar"}),
        ]
    )

    sync_client.messages.create(
        max_tokens=1024,
        messages=[
            {
                "role": "user",
                "content": "Say hello there!",
            }
        ],
        model="anthropic.claude-3-5-sonnet-20241022-v2:0",
    )

    calls = cast("list[MockRequestCall]", respx_mock.calls)

    assert len(calls) == 2

    assert (
        calls[0].request.url
        == "https://bedrock-runtime.us-east-1.amazonaws.com/model/anthropic.claude-3-5-sonnet-20241022-v2:0/invoke"
    )
    assert (
        calls[1].request.url
        == "https://bedrock-runtime.us-east-1.amazonaws.com/model/anthropic.claude-3-5-sonnet-20241022-v2:0/invoke"
    )

Subdomains

Frequently Asked Questions

What does test_messages_retries() do?
test_messages_retries() is a function in the anthropic-sdk-python codebase, defined in tests/lib/test_bedrock.py.
Where is test_messages_retries() defined?
test_messages_retries() is defined in tests/lib/test_bedrock.py at line 66.

Analyze Your Own Codebase

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

Try Supermodel Free