@@ -141,7 +141,8 @@ def test_runsync(self):
141141 with patch (f"{ module_location } .FastAPI" , Mock ()), \
142142 patch (f"{ module_location } .APIRouter" , return_value = Mock ()), \
143143 patch (f"{ module_location } .uvicorn" , Mock ()), \
144- patch (f"{ module_location } .uuid.uuid4" , return_value = "123" ):
144+ patch (f"{ module_location } .uuid.uuid4" , return_value = "123" ), \
145+ patch (f"{ module_location } .threading" ) as mock_threading :
145146
146147 default_input_object = rp_fastapi .DefaultRequest (
147148 input = {"test_input" : "test_input" }
@@ -183,9 +184,8 @@ def generator_handler(job):
183184 assert "error" in error_runsync_return
184185
185186 # Test webhook caller sent
186- with patch (f"{ module_location } .threading" ) as mock_thread :
187- asyncio .run (worker_api ._sim_runsync (input_object_with_webhook ))
188- assert mock_thread .Thread .called
187+ asyncio .run (worker_api ._sim_runsync (input_object_with_webhook ))
188+ assert mock_threading .Thread .called
189189
190190 loop .close ()
191191
@@ -201,7 +201,7 @@ def test_stream(self):
201201 patch (f"{ module_location } .APIRouter" , return_value = Mock ()), \
202202 patch (f"{ module_location } .uvicorn" , Mock ()), \
203203 patch (f"{ module_location } .uuid.uuid4" , return_value = "123" ), \
204- patch (f"{ module_location } .threading" ):
204+ patch (f"{ module_location } .threading" ) as mock_threading :
205205
206206 default_input_object = rp_fastapi .DefaultRequest (
207207 input = {"test_input" : "test_input" }
@@ -232,10 +232,9 @@ def test_stream(self):
232232 }
233233
234234 # Test webhook caller sent
235- with patch (f"{ module_location } .threading" , return_value = True ) as mock_threading :
236- asyncio .run (worker_api ._sim_run (input_object_with_webhook ))
237- asyncio .run (worker_api ._sim_stream ("test-123" ))
238- assert mock_threading .Thread .called
235+ asyncio .run (worker_api ._sim_run (input_object_with_webhook ))
236+ asyncio .run (worker_api ._sim_stream ("test-123" ))
237+ assert mock_threading .Thread .called
239238
240239 # Test with generator handler
241240 def generator_handler (job ):
@@ -265,7 +264,7 @@ def test_status(self):
265264 patch (f"{ module_location } .APIRouter" , return_value = Mock ()), \
266265 patch (f"{ module_location } .uvicorn" , Mock ()), \
267266 patch (f"{ module_location } .uuid.uuid4" , return_value = "123" ), \
268- patch (f"{ module_location } .threading" ):
267+ patch (f"{ module_location } .threading" ) as mock_threading :
269268
270269 worker_api = rp_fastapi .WorkerAPI ({"handler" : self .handler })
271270
@@ -296,10 +295,9 @@ def test_status(self):
296295 }
297296
298297 # Test webhook caller sent
299- with patch (f"{ module_location } .threading" , return_value = True ) as mock_threading :
300- asyncio .run (worker_api ._sim_run (input_object_with_webhook ))
301- asyncio .run (worker_api ._sim_status ("test-123" ))
302- assert mock_threading .Thread .called
298+ asyncio .run (worker_api ._sim_run (input_object_with_webhook ))
299+ asyncio .run (worker_api ._sim_status ("test-123" ))
300+ assert mock_threading .Thread .called
303301
304302 # Test with generator handler
305303 def generator_handler (job ):
0 commit comments