Skip to content

Commit ecf9173

Browse files
committed
tests: cov
1 parent 76acfa7 commit ecf9173

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

tests/test_direct_sync_stream.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import asyncio
44
import re
5+
import threading
56
from unittest.mock import AsyncMock, Mock, patch
67

78
import pytest
@@ -204,6 +205,18 @@ def test_model_request_stream_sync_repr_no_stream():
204205
assert 'context_entered=False' in repr_str
205206

206207

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+
207220
def test_model_request_stream_sync_stream_ready_failure():
208221
"""Test stream initialization failure after timeout."""
209222
async_stream_mock = AsyncMock()

0 commit comments

Comments
 (0)