test(anthropic): cover attempt-scoped interruption logging

This commit is contained in:
yyobject 2026-10-27 13:16:11 +08:00
parent 6bd10f8adf
commit 647a962f41

View file

@ -182,6 +182,9 @@ async def test_interrupted_anthropic_stream_recovers_output_tokens_off_the_event
logging_obj.get_router_model_id.return_value = None
logging_obj.dispatch_success_handlers = AsyncMock()
logging_obj.dispatch_failure_handlers = AsyncMock()
logging_obj.dispatch_attempt_failure_handlers = AsyncMock(
side_effect=logging_obj.dispatch_failure_handlers
)
_, took, lags = await timed_with_loop_lags(
lambda: PassThroughStreamingHandler._route_streaming_logging_to_handler(
@ -198,6 +201,7 @@ async def test_interrupted_anthropic_stream_recovers_output_tokens_off_the_event
)
logging_obj.dispatch_success_handlers.assert_not_awaited()
logging_obj.dispatch_attempt_failure_handlers.assert_awaited_once()
logging_obj.dispatch_failure_handlers.assert_awaited_once()
logged_usage = logging_obj.record_partial_usage_for_failure.call_args.kwargs["usage"]
assert logged_usage.completion_tokens > 100_000