Skip to content

Commit 54cd464

Browse files
wesmclaude
andcommitted
test: Speed up retry logic tests (14s → 2s)
Reduced wait times in retry tests for much faster execution: - test_exponential_backoff_timing: 1s/2s/4s → 50ms/100ms/200ms - test_initial_wait_configurable: 5s → 50ms Tests still verify the same behavior (exponential backoff math, actual waiting) but don't spend unnecessary time waiting. Before: 14.4 seconds After: 2.3 seconds (6x faster!) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent f730c44 commit 54cd464

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

tests/test_retry_logic.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -157,17 +157,17 @@ def on_retry_callback(attempt: int, wait_seconds: float):
157157
operation=failing_operation,
158158
operation_name="Backoff test",
159159
max_retries=5,
160-
initial_wait=1.0,
160+
initial_wait=0.05, # 50ms for faster tests
161161
on_retry=on_retry_callback
162162
)
163163

164164
# Should have 3 retries (attempts 1, 2, 3)
165165
assert len(retry_times) == 3
166166

167-
# Check exponential backoff: 1s, 2s, 4s
168-
assert retry_times[0] == (1, 1.0) # 1.0 * 2^0 = 1
169-
assert retry_times[1] == (2, 2.0) # 1.0 * 2^1 = 2
170-
assert retry_times[2] == (3, 4.0) # 1.0 * 2^2 = 4
167+
# Check exponential backoff: 0.05s, 0.1s, 0.2s
168+
assert retry_times[0] == (1, 0.05) # 0.05 * 2^0 = 0.05
169+
assert retry_times[1] == (2, 0.1) # 0.05 * 2^1 = 0.1
170+
assert retry_times[2] == (3, 0.2) # 0.05 * 2^2 = 0.2
171171

172172
@pytest.mark.asyncio
173173
async def test_on_retry_callback_invoked(self):
@@ -282,19 +282,19 @@ async def failing_operation():
282282
def callback(attempt: int, wait_seconds: float):
283283
retry_waits.append(wait_seconds)
284284

285-
# Custom initial wait of 5 seconds
285+
# Custom initial wait of 0.05 seconds (50ms)
286286
with pytest.raises(Exception):
287287
await retry_with_backoff(
288288
operation=failing_operation,
289289
operation_name="Test",
290290
max_retries=2,
291-
initial_wait=5.0,
291+
initial_wait=0.05,
292292
on_retry=callback
293293
)
294294

295295
# Should have 1 retry (attempt 1)
296296
assert len(retry_waits) == 1
297-
assert retry_waits[0] == 5.0 # 5.0 * 2^0 = 5
297+
assert retry_waits[0] == 0.05 # 0.05 * 2^0 = 0.05
298298

299299
@pytest.mark.asyncio
300300
async def test_actual_wait_occurs(self):

0 commit comments

Comments
 (0)