From 57f898f2052611fc293dc278a8fdfc226e01ecbc Mon Sep 17 00:00:00 2001 From: Kirill Losev Date: Sun, 30 Aug 2026 15:07:31 +0300 Subject: [PATCH] test(docker_model_runner): satisfy test-quality gate in provider tests Drop copy-pasted sys.path inserts (TQ003), assert the dispatch return value instead of only mock kwargs (TQ002), and mark the two shared handler patches with their seam justification (TQ008) --- ...st_docker_model_runner_chat_transformation.py | 4 ---- ...ker_model_runner_completion_transformation.py | 5 ----- .../test_docker_model_runner_dispatch.py | 16 +++++++++------- ...cker_model_runner_embedding_transformation.py | 4 ---- ..._docker_model_runner_images_transformation.py | 4 ---- ..._docker_model_runner_rerank_transformation.py | 4 ---- 6 files changed, 9 insertions(+), 28 deletions(-) diff --git a/tests/test_litellm/llms/docker_model_runner/test_docker_model_runner_chat_transformation.py b/tests/test_litellm/llms/docker_model_runner/test_docker_model_runner_chat_transformation.py index 9ee7300d916..f0366d4792c 100644 --- a/tests/test_litellm/llms/docker_model_runner/test_docker_model_runner_chat_transformation.py +++ b/tests/test_litellm/llms/docker_model_runner/test_docker_model_runner_chat_transformation.py @@ -7,15 +7,11 @@ parameter mapping, and request/response transformation. """ import json -import os -import sys from typing import List from unittest.mock import MagicMock, patch import pytest -sys.path.insert(0, os.path.abspath("../../../../..")) - from litellm.llms.docker_model_runner.chat.transformation import ( DockerModelRunnerChatConfig, ) diff --git a/tests/test_litellm/llms/docker_model_runner/test_docker_model_runner_completion_transformation.py b/tests/test_litellm/llms/docker_model_runner/test_docker_model_runner_completion_transformation.py index 871466bd997..4dc12cd38d4 100644 --- a/tests/test_litellm/llms/docker_model_runner/test_docker_model_runner_completion_transformation.py +++ b/tests/test_litellm/llms/docker_model_runner/test_docker_model_runner_completion_transformation.py @@ -5,13 +5,8 @@ This test verifies that the DockerModelRunnerCompletionConfig correctly transfor text completion requests and handles URL generation for the Docker Model Runner API. """ -import os -import sys - import pytest -sys.path.insert(0, os.path.abspath("../../../../..")) # Adds the parent directory to the system path - from litellm.llms.docker_model_runner.completion.transformation import ( DockerModelRunnerCompletionConfig, ) diff --git a/tests/test_litellm/llms/docker_model_runner/test_docker_model_runner_dispatch.py b/tests/test_litellm/llms/docker_model_runner/test_docker_model_runner_dispatch.py index b2fc2495c25..330311a2202 100644 --- a/tests/test_litellm/llms/docker_model_runner/test_docker_model_runner_dispatch.py +++ b/tests/test_litellm/llms/docker_model_runner/test_docker_model_runner_dispatch.py @@ -1,11 +1,7 @@ """Tests for the Docker Model Runner dispatch wiring in litellm/main.py.""" -import os -import sys from unittest.mock import MagicMock, patch -sys.path.insert(0, os.path.abspath("../../../..")) - import litellm from litellm.main import _complete_docker_model_runner from litellm.types.completion import _CompletionDispatchContext @@ -51,7 +47,9 @@ def test_complete_docker_model_runner_uses_shared_http_handler(): ctx = _make_ctx() sentinel = MagicMock(name="response") - with patch("litellm.main.base_llm_http_handler.completion", return_value=sentinel) as mock_completion: + with patch( # test-quality-ok: the dispatch's only injection seam is the shared handler sink + "litellm.main.base_llm_http_handler.completion", return_value=sentinel + ) as mock_completion: result = _complete_docker_model_runner(ctx) assert result is sentinel @@ -66,8 +64,12 @@ def test_complete_docker_model_runner_respects_env_api_base(monkeypatch): """DOCKER_MODEL_RUNNER_API_BASE is picked up when no explicit api_base is set.""" monkeypatch.setenv("DOCKER_MODEL_RUNNER_API_BASE", "http://model-runner.docker.internal:12434/engines/v1") ctx = _make_ctx() + sentinel = MagicMock(name="response") - with patch("litellm.main.base_llm_http_handler.completion", return_value=MagicMock()) as mock_completion: - _complete_docker_model_runner(ctx) + with patch( # test-quality-ok: the dispatch's only injection seam is the shared handler sink + "litellm.main.base_llm_http_handler.completion", return_value=sentinel + ) as mock_completion: + result = _complete_docker_model_runner(ctx) + assert result is sentinel assert mock_completion.call_args.kwargs["api_base"] == "http://model-runner.docker.internal:12434/engines/v1" diff --git a/tests/test_litellm/llms/docker_model_runner/test_docker_model_runner_embedding_transformation.py b/tests/test_litellm/llms/docker_model_runner/test_docker_model_runner_embedding_transformation.py index 044d0171a1f..e0680b4e587 100644 --- a/tests/test_litellm/llms/docker_model_runner/test_docker_model_runner_embedding_transformation.py +++ b/tests/test_litellm/llms/docker_model_runner/test_docker_model_runner_embedding_transformation.py @@ -6,14 +6,10 @@ embedding requests and handles URL generation for the Docker Model Runner API. """ import json -import os -import sys from unittest.mock import MagicMock import pytest -sys.path.insert(0, os.path.abspath("../../../../..")) # Adds the parent directory to the system path - from litellm.llms.docker_model_runner.embedding.transformation import ( DockerModelRunnerEmbeddingConfig, ) diff --git a/tests/test_litellm/llms/docker_model_runner/test_docker_model_runner_images_transformation.py b/tests/test_litellm/llms/docker_model_runner/test_docker_model_runner_images_transformation.py index f5c2dde77d2..3404ed09a7b 100644 --- a/tests/test_litellm/llms/docker_model_runner/test_docker_model_runner_images_transformation.py +++ b/tests/test_litellm/llms/docker_model_runner/test_docker_model_runner_images_transformation.py @@ -7,14 +7,10 @@ Diffusers backend of Docker Model Runner. """ import json -import os -import sys from unittest.mock import MagicMock import pytest -sys.path.insert(0, os.path.abspath("../../../../..")) # Adds the parent directory to the system path - from litellm.llms.docker_model_runner.images.transformation import ( DockerModelRunnerImageGenerationConfig, ) diff --git a/tests/test_litellm/llms/docker_model_runner/test_docker_model_runner_rerank_transformation.py b/tests/test_litellm/llms/docker_model_runner/test_docker_model_runner_rerank_transformation.py index 14a1fc4d3c1..66adb30afff 100644 --- a/tests/test_litellm/llms/docker_model_runner/test_docker_model_runner_rerank_transformation.py +++ b/tests/test_litellm/llms/docker_model_runner/test_docker_model_runner_rerank_transformation.py @@ -6,14 +6,10 @@ rerank requests and handles both llama.cpp and vLLM response formats. """ import json -import os -import sys from unittest.mock import MagicMock import pytest -sys.path.insert(0, os.path.abspath("../../../../..")) # Adds the parent directory to the system path - from litellm.llms.docker_model_runner.rerank.transformation import ( DockerModelRunnerRerankConfig, )