From 7149e0f2471f2c78d37568e3f8cd52e75d11e60b Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Fri, 4 Sep 2026 07:02:59 +0000 Subject: [PATCH] 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> --- tests/test_speed.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/test_speed.py b/tests/test_speed.py index 3722359..9dc9e57 100644 --- a/tests/test_speed.py +++ b/tests/test_speed.py @@ -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