test: add test for BaseException catch block in measure_speed cascade

Adds a test `test_cascade_catches_base_exception` in `tests/test_speed.py` to ensure that custom exceptions subclassing `BaseException` are correctly caught by the cascade handler, recorded as failed tier attempts, and do not bubble up to crash the execution.

Co-authored-by: Horizontal42 <75383519+Horizontal42@users.noreply.github.com>
This commit is contained in:
google-labs-jules[bot] 2026-09-04 07:02:59 +00:00
parent 8c99ac78b7
commit 7149e0f247

View file

@ -245,6 +245,20 @@ async def test_cascade_records_exception_class_name_when_no_message_provided():
assert result.tier_attempts[0].reason == "Exception"
async def test_cascade_catches_base_exception():
class MyBaseException(BaseException):
pass
async def bad() -> SpeedResult:
raise MyBaseException("base error")
result = await run_speed_cascade([("bad", bad)])
assert result.method == "none"
assert len(result.tier_attempts) == 1
assert result.tier_attempts[0].ok is False
assert result.tier_attempts[0].reason == "base error"
async def test_cascade_never_swallows_cancellation():
import asyncio