mirror of
https://github.com/Horizontal42/netsleuth.git
synced 2026-11-10 22:42:03 +03:00
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:
parent
8c99ac78b7
commit
7149e0f247
1 changed files with 14 additions and 0 deletions
|
|
@ -245,6 +245,20 @@ async def test_cascade_records_exception_class_name_when_no_message_provided():
|
||||||
assert result.tier_attempts[0].reason == "Exception"
|
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():
|
async def test_cascade_never_swallows_cancellation():
|
||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue