diff --git a/tests/test_litellm/litellm_core_utils/test_streaming_handler.py b/tests/test_litellm/litellm_core_utils/test_streaming_handler.py index 18b61a82ea6..0a96d2d466b 100644 --- a/tests/test_litellm/litellm_core_utils/test_streaming_handler.py +++ b/tests/test_litellm/litellm_core_utils/test_streaming_handler.py @@ -4915,10 +4915,14 @@ async def test_clean_eof_without_finish_reason_raises_midstream_error_issue_4026 ) chunks = [] - with pytest.raises(MidStreamFallbackError) as excinfo: + + async def _consume(): async for c in wrapper: chunks.append(c) + with pytest.raises(MidStreamFallbackError) as excinfo: + await _consume() + assert chunks, "partial content should have been yielded before the error" assert all(getattr(c.choices[0], "finish_reason", None) is None for c in chunks) assert wrapper.received_finish_reason is None