Skip to content

Commit 9aa4dd5

Browse files
Fix: pre-commit errors on main (#574)
* fix: tests/unit/test_batch.py:173:5: PT031 `pytest.warns()` block should contain a single simple statement * fix: refactor test_server_terminate to improve readability of patch context * rem comment * update --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 7b6d425 commit 9aa4dd5

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

tests/unit/test_batch.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,12 +170,12 @@ def test_batch_predict_string_warning():
170170

171171
mock_input = torch.tensor([[1.0], [2.0]])
172172

173+
# Simulate the behavior in run_batched_loop
174+
y = api.predict(mock_input)
173175
with pytest.warns(
174176
UserWarning,
175177
match="When batching is enabled, 'predict' must return a list to handle multiple inputs correctly.",
176178
):
177-
# Simulate the behavior in run_batched_loop
178-
y = api.predict(mock_input)
179179
api.unbatch(y)
180180

181181

tests/unit/test_lit_server.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -317,11 +317,11 @@ def test_server_terminate():
317317
server.verify_worker_status = MagicMock()
318318
server._transport = MagicMock()
319319

320-
with (
321-
patch("litserve.server.LitServer._init_manager", return_value=MagicMock()) as mock_init_manager,
322-
patch("litserve.server.LitServer._start_server", side_effect=Exception("mocked error")) as mock_start,
323-
patch("litserve.server.LitServer.launch_inference_worker", return_value=([MagicMock()])) as mock_launch,
324-
):
320+
with patch("litserve.server.LitServer._init_manager", return_value=MagicMock()) as mock_init_manager, patch(
321+
"litserve.server.LitServer._start_server", side_effect=Exception("mocked error")
322+
) as mock_start, patch(
323+
"litserve.server.LitServer.launch_inference_worker", return_value=([MagicMock()])
324+
) as mock_launch:
325325
with pytest.raises(Exception, match="mocked error"):
326326
server.run(port=8001)
327327

0 commit comments

Comments
 (0)