Merge pull request #23213 from BerriAI/litellm_fix_flaky_audio_stream_test

[Fix] Flaky test_stream_chunk_builder_openai_audio_output_usage
This commit is contained in:
yuneng-jiang 2026-03-09 17:32:17 -07:00 committed by GitHub
commit 0e2aa7a5b2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -636,7 +636,7 @@ def test_stream_chunk_builder_openai_prompt_caching():
assert response_usage_value == v
@pytest.mark.flaky(retries=3, delay=2)
@pytest.mark.flaky(retries=5, delay=2)
def test_stream_chunk_builder_openai_audio_output_usage():
from pydantic import BaseModel
from openai import OpenAI
@ -667,13 +667,15 @@ def test_stream_chunk_builder_openai_audio_output_usage():
usage_obj: Optional[litellm.Usage] = None
for index, chunk in enumerate(chunks):
if hasattr(chunk, "usage"):
if hasattr(chunk, "usage") and chunk.usage is not None:
usage_obj = chunk.usage
print(f"chunk usage: {chunk.usage}")
print(f"index: {index}")
print(f"len chunks: {len(chunks)}")
print(f"usage_obj: {usage_obj}")
if usage_obj is None:
pytest.skip("OpenAI did not return usage data in streaming response")
response = stream_chunk_builder(chunks=chunks)
print(f"response usage: {response.usage}")
check_non_streaming_response(response)