File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change 2
2
3
3
import asyncio
4
4
import re
5
+ import threading
5
6
from unittest .mock import AsyncMock , Mock , patch
6
7
7
8
import pytest
@@ -204,6 +205,18 @@ def test_model_request_stream_sync_repr_no_stream():
204
205
assert 'context_entered=False' in repr_str
205
206
206
207
208
+ def test_streamed_response_sync_start_producer_and_repr ():
209
+ mock_cm = Mock ()
210
+ srs = StreamedResponseSync (_async_stream_cm = mock_cm )
211
+ srs ._start_producer () # pyright: ignore[reportPrivateUsage]
212
+ t = srs ._thread # pyright: ignore[reportPrivateUsage]
213
+ assert isinstance (t , threading .Thread )
214
+ srs ._start_producer () # pyright: ignore[reportPrivateUsage]
215
+ assert srs ._thread is t # pyright: ignore[reportPrivateUsage]
216
+ r = repr (srs )
217
+ assert r .startswith ('StreamedResponseSync' ) and 'context_entered' in r
218
+
219
+
207
220
def test_model_request_stream_sync_stream_ready_failure ():
208
221
"""Test stream initialization failure after timeout."""
209
222
async_stream_mock = AsyncMock ()
You can’t perform that action at this time.
0 commit comments