@@ -62,6 +62,13 @@ def run(self, body, path: str, origin_name: Optional[str] = None) -> Generator:
6262 raise ValueError ("Simulated streaming error" )
6363
6464
65+ class NonStreamingRunnable (ParallelExecutionRunnable ):
66+ """A non-streaming runnable that returns a single value."""
67+
68+ def run (self , body , path : str , origin_name : Optional [str ] = None ):
69+ return f"{ body } _result"
70+
71+
6572class TestStreamingPrimitives :
6673 """Tests for streaming primitive classes."""
6774
@@ -120,6 +127,46 @@ async def coro():
120127 c .close ()
121128
122129
130+ class TestIsStreamingMethod :
131+ """Tests for ParallelExecutionRunnable.is_streaming() method."""
132+
133+ def test_is_streaming_sync_generator (self ):
134+ """Test that a runnable with a sync generator run() is detected as streaming."""
135+ runnable = StreamingRunnable (name = "test" )
136+ assert runnable .is_streaming () is True
137+
138+ def test_is_streaming_async_generator (self ):
139+ """Test that a runnable with an async generator run_async() is detected as streaming."""
140+ runnable = AsyncStreamingRunnable (name = "test" )
141+ assert runnable .is_streaming () is True
142+
143+ def test_is_streaming_non_generator (self ):
144+ """Test that a runnable with a non-generator run() is not detected as streaming."""
145+ runnable = NonStreamingRunnable (name = "test" )
146+ assert runnable .is_streaming () is False
147+
148+ def test_is_streaming_base_class (self ):
149+ """Test that the base ParallelExecutionRunnable is not streaming by default."""
150+ runnable = ParallelExecutionRunnable (name = "test" )
151+ assert runnable .is_streaming () is False
152+
153+ def test_is_streaming_override (self ):
154+ """Test that is_streaming() can be overridden by subclasses."""
155+
156+ class OverriddenRunnable (ParallelExecutionRunnable ):
157+ """A runnable that overrides is_streaming() to return True."""
158+
159+ def is_streaming (self ) -> bool :
160+ return True
161+
162+ def run (self , body , path : str , origin_name : Optional [str ] = None ):
163+ # Even though run() is not a generator, is_streaming() returns True
164+ return f"{ body } _result"
165+
166+ runnable = OverriddenRunnable (name = "test" )
167+ assert runnable .is_streaming () is True
168+
169+
123170class TestMapStreaming :
124171 """Tests for Map step streaming support."""
125172
0 commit comments