From b3483a6af691a0346ec50839bb7caf21c1541d47 Mon Sep 17 00:00:00 2001 From: James Ding Date: Tue, 16 Dec 2025 15:09:10 -0600 Subject: [PATCH 1/2] fix: allow non s prefixed models to fail websocket integration tests --- .../test_tts_websocket_integration.py | 80 ++++++++++--------- 1 file changed, 43 insertions(+), 37 deletions(-) diff --git a/tests/integration/test_tts_websocket_integration.py b/tests/integration/test_tts_websocket_integration.py index f297b2d..f83505b 100644 --- a/tests/integration/test_tts_websocket_integration.py +++ b/tests/integration/test_tts_websocket_integration.py @@ -35,25 +35,28 @@ def text_stream(): save_audio(audio_chunks, "test_websocket_streaming.mp3") @pytest.mark.flaky(reruns=9, reruns_delay=1) - def test_websocket_streaming_with_different_models(self, client, save_audio): - """Test WebSocket streaming with different models.""" - import time + @pytest.mark.parametrize( + "model", + [ + pytest.param( + m, marks=pytest.mark.xfail(reason="WebSocket unreliable for legacy models") + ) + if not m.startswith("s1") + else m + for m in get_args(Model) + ], + ) + def test_websocket_streaming_with_model(self, client, save_audio, model): + """Test WebSocket streaming with a specific model.""" - models = get_args(Model) - - for model in models: - - def text_stream(): - yield f"Testing model {model} via WebSocket." - - audio_chunks = list(client.tts.stream_websocket(text_stream(), model=model)) - assert len(audio_chunks) > 0, f"Failed for model: {model}" + def text_stream(): + yield f"Testing model {model} via WebSocket." - # Write to output directory - save_audio(audio_chunks, f"test_websocket_model_{model}.mp3") + audio_chunks = list(client.tts.stream_websocket(text_stream(), model=model)) + assert len(audio_chunks) > 0, f"Failed for model: {model}" - # Brief delay to avoid SSL errors when opening next WebSocket connection - time.sleep(1.0) + # Write to output directory + save_audio(audio_chunks, f"test_websocket_model_{model}.mp3") def test_websocket_streaming_with_wav_format(self, client, save_audio): """Test WebSocket streaming with WAV format.""" @@ -221,32 +224,35 @@ async def text_stream(): @pytest.mark.asyncio @pytest.mark.flaky(reruns=9, reruns_delay=1) - async def test_async_websocket_streaming_with_different_models( - self, async_client, save_audio + @pytest.mark.parametrize( + "model", + [ + pytest.param( + m, marks=pytest.mark.xfail(reason="WebSocket unreliable for legacy models") + ) + if not m.startswith("s1") + else m + for m in get_args(Model) + ], + ) + async def test_async_websocket_streaming_with_model( + self, async_client, save_audio, model ): - """Test async WebSocket streaming with different models.""" - import asyncio - - models = get_args(Model) + """Test async WebSocket streaming with a specific model.""" - for model in models: - - async def text_stream(): - yield f"Testing model {model} via async WebSocket." - - audio_chunks = [] - async for chunk in async_client.tts.stream_websocket( - text_stream(), model=model - ): - audio_chunks.append(chunk) + async def text_stream(): + yield f"Testing model {model} via async WebSocket." - assert len(audio_chunks) > 0, f"Failed for model: {model}" + audio_chunks = [] + async for chunk in async_client.tts.stream_websocket( + text_stream(), model=model + ): + audio_chunks.append(chunk) - # Write to output directory - save_audio(audio_chunks, f"test_async_websocket_model_{model}.mp3") + assert len(audio_chunks) > 0, f"Failed for model: {model}" - # Brief delay to avoid SSL errors when opening next WebSocket connection - await asyncio.sleep(1.0) + # Write to output directory + save_audio(audio_chunks, f"test_async_websocket_model_{model}.mp3") @pytest.mark.asyncio async def test_async_websocket_streaming_with_format( From 9dbe67aaf6bd027a9a8f87e62512649058ce6a22 Mon Sep 17 00:00:00 2001 From: James Ding Date: Tue, 16 Dec 2025 15:09:58 -0600 Subject: [PATCH 2/2] style: fix formatting --- tests/integration/test_tts_websocket_integration.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/integration/test_tts_websocket_integration.py b/tests/integration/test_tts_websocket_integration.py index f83505b..5014dab 100644 --- a/tests/integration/test_tts_websocket_integration.py +++ b/tests/integration/test_tts_websocket_integration.py @@ -39,7 +39,10 @@ def text_stream(): "model", [ pytest.param( - m, marks=pytest.mark.xfail(reason="WebSocket unreliable for legacy models") + m, + marks=pytest.mark.xfail( + reason="WebSocket unreliable for legacy models" + ), ) if not m.startswith("s1") else m @@ -228,7 +231,10 @@ async def text_stream(): "model", [ pytest.param( - m, marks=pytest.mark.xfail(reason="WebSocket unreliable for legacy models") + m, + marks=pytest.mark.xfail( + reason="WebSocket unreliable for legacy models" + ), ) if not m.startswith("s1") else m