Skip to content

Commit 74d7204

Browse files
committed
Update reset failure processor tests
Revise processor reset tests to match the new non-throwing failure path: reset now returns `False` when the worker does not stop instead of raising. Also add coverage to ensure runtime statistics remain unchanged when reset fails.
1 parent ed9bc1d commit 74d7204

1 file changed

Lines changed: 31 additions & 6 deletions

File tree

‎tests/services/inference/test_processor.py‎

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ def test_reset_clears_statistics() -> None:
212212
assert stats.processing_fps == 0.0
213213

214214

215-
def test_reset_raises_when_worker_does_not_stop(
215+
def test_reset_returns_false_when_worker_does_not_stop(
216216
monkeypatch,
217217
) -> None:
218218
processor = PoseProcessor()
@@ -223,11 +223,36 @@ def test_reset_raises_when_worker_does_not_stop(
223223
lambda: False,
224224
)
225225

226-
with pytest.raises(
227-
RuntimeError,
228-
match="Failed to stop worker thread",
229-
):
230-
processor.reset()
226+
stopped = processor.reset()
227+
228+
assert stopped is False
229+
230+
231+
def test_failed_reset_preserves_runtime_statistics(
232+
monkeypatch,
233+
) -> None:
234+
processor = PoseProcessor()
235+
processor._frames_enqueued = 4
236+
processor._frames_processed = 3
237+
processor._frames_dropped = 2
238+
processor._latencies.append(1.0)
239+
240+
monkeypatch.setattr(
241+
processor,
242+
"_stop_worker",
243+
lambda: False,
244+
)
245+
246+
stopped = processor.reset()
247+
248+
assert stopped is False
249+
250+
stats = processor.get_stats()
251+
252+
assert stats.frames_enqueued == 4
253+
assert stats.frames_processed == 3
254+
assert stats.frames_dropped == 2
255+
assert stats.average_latency == 1.0
231256

232257

233258
def test_create_dlc_pose_processor() -> None:

0 commit comments

Comments
 (0)