From b352fb68a0d1a115c0f5c6286e776834b3955eea Mon Sep 17 00:00:00 2001 From: Jared Atkinson Date: Fri, 20 Nov 2026 08:45:39 -0800 Subject: [PATCH] fix: BED-10669 isolate retry-budget tests from local configuration --- tests/test_github_rest_client.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/tests/test_github_rest_client.py b/tests/test_github_rest_client.py index 508303c7..5a7b81c9 100644 --- a/tests/test_github_rest_client.py +++ b/tests/test_github_rest_client.py @@ -111,14 +111,23 @@ def test_mixed_server_and_network_failures_share_budget(monkeypatch): assert send.call_count == 3 -def test_rate_limit_retries_do_not_consume_transient_budget(monkeypatch): +@pytest.mark.parametrize("max_attempts", [5, 7]) +def test_rate_limit_retries_do_not_consume_transient_budget(monkeypatch, max_attempts): + # Keep the overall DLT limit explicit: four rate limits followed by two + # transient failures need seven attempts to reach the successful response. + monkeypatch.setenv("RUNTIME__REQUEST_MAX_ATTEMPTS", str(max_attempts)) session, send = _session(monkeypatch, [ *[make_response(429, body={"message": "secondary rate limit"}) for _ in range(4)], make_response(503), make_response(503), make_response(200), ]) - assert session.get("https://api.github.com/example").status_code == 200 - assert send.call_count == 7 + if max_attempts == 5: + with pytest.raises(HTTPError) as caught: + session.get("https://api.github.com/example") + assert caught.value.response.status_code == 503 + else: + assert session.get("https://api.github.com/example").status_code == 200 + assert send.call_count == max_attempts @pytest.mark.parametrize(("status", "headers", "body"), [