From 6127c28dd88fb05cc0567fe749a8e01cb5b18c77 Mon Sep 17 00:00:00 2001 From: Mohsen Azimi Date: Mon, 2 Nov 2026 15:30:41 +0100 Subject: [PATCH] test: control the retry-after deadline clock Assert the requested delay against the remaining deadline through the existing clock fixture in both client modes. Real transport receipt no longer competes with a 50 ms test budget. Co-Authored-By: Codex (GPT-6.1) --- tests/test_http.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tests/test_http.py b/tests/test_http.py index eba316e..c543b02 100644 --- a/tests/test_http.py +++ b/tests/test_http.py @@ -1054,17 +1054,19 @@ async def test_polling_backoff_and_timeout_keep_review_url_and_last_record( @MODES -async def test_retry_after_is_bounded_by_wait_deadline(mode: str) -> None: +async def test_retry_after_is_bounded_by_wait_deadline( + mode: str, monkeypatch: pytest.MonkeyPatch +) -> None: + clock = Clock(monkeypatch) with Server( - lambda request, index: Reply(503, {"detail": "Unavailable."}, {"Retry-After": "2"}) + lambda request, index: Reply(503, {"detail": "Unavailable."}, {"Retry-After": "20"}) ) as server: async with session(mode, server.url) as client: - started = time.monotonic() - result = await call(client, "wait_for_review", ORG, REVIEW, timeout=0.05) + result = await call(client, "wait_for_review", ORG, REVIEW, timeout=10) assert result.status == "TIMED_OUT" assert result.review_url == f"{server.url}/orgs/by-id/{ORG}/reviews/{REVIEW}" - assert time.monotonic() - started < 0.5 assert len(server.requests) == 1 + assert clock.delays == [10] @MODES