From 6c46f8f6514c4e7bf26aec04b01b4aca7a4b2fd1 Mon Sep 17 00:00:00 2001 From: Joshua Valluru <326636767+joshua-berri@users.noreply.github.com> Date: Sat, 26 Sep 2026 23:46:55 -0700 Subject: [PATCH] fix(mcp): isolate helper coverage from test proxy startup --- tests/integration/_support/process.py | 2 ++ tests/integration/conformance_coverage.toml | 2 +- .../integration_support/test_conformance.py | 28 +++++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/tests/integration/_support/process.py b/tests/integration/_support/process.py index fcbaf7c8d8c..9d5d7a17db7 100644 --- a/tests/integration/_support/process.py +++ b/tests/integration/_support/process.py @@ -103,6 +103,8 @@ def owned_proxy_process( "LITELLM_MASTER_KEY": gateway.key, "LITELLM_SALT_KEY": os.environ.get("LITELLM_SALT_KEY", "sk-integration-salt"), "STORE_MODEL_IN_DB": "True", + "COVERAGE_PROCESS_CONFIG": "", + "COVERAGE_PROCESS_START": "", **overrides, } output: Final = Path(os.environ.get("INTEGRATION_RESULTS_DIR", str(directory))) diff --git a/tests/integration/conformance_coverage.toml b/tests/integration/conformance_coverage.toml index 05fc59533b1..ca1c2724341 100644 --- a/tests/integration/conformance_coverage.toml +++ b/tests/integration/conformance_coverage.toml @@ -3,7 +3,7 @@ branch = true parallel = true relative_files = true patch = ["subprocess"] -include = ["tests/integration/_support/conformance.py"] +include = ["tests/integration/_support/conformance.py", "tests/integration/_support/process.py"] [tool.coverage.report] show_missing = true diff --git a/tests/unit/integration_support/test_conformance.py b/tests/unit/integration_support/test_conformance.py index 9c2327ff230..3dfa171a610 100644 --- a/tests/unit/integration_support/test_conformance.py +++ b/tests/unit/integration_support/test_conformance.py @@ -1,13 +1,41 @@ import hashlib import json +import os from pathlib import Path from typing import Final +from unittest.mock import Mock, patch import pytest from tests.integration._support.conformance import read_checks, verify_archive, prefixed_request from pydantic import ValidationError +@pytest.mark.parametrize("explicit", (False, True)) +def test_owned_proxy_isolates_automatic_coverage_unless_requested( + tmp_path: Path, monkeypatch: pytest.MonkeyPatch, explicit: bool +) -> None: + from integration._support.client import Gateway + from integration._support.process import owned_proxy_process + + monkeypatch.setenv("COVERAGE_PROCESS_CONFIG", "parent-config") + monkeypatch.setenv("COVERAGE_PROCESS_START", "parent.toml") + overrides: Final = {"COVERAGE_PROCESS_CONFIG": "child-config"} if explicit else {} + gateway: Final = Gateway(Mock(), "owner-key", "http://upstream") + with ( + patch("integration._support.process.subprocess.Popen") as spawn, + patch("integration._support.process.httpx.Client") as client, + patch("integration._support.process.group_members", return_value=()), + ): + spawn.return_value.poll.return_value = None + client.return_value.__enter__.return_value.get.return_value.status_code = 200 + with owned_proxy_process(gateway, tmp_path, overrides): + child: Final = spawn.call_args.kwargs["env"] + assert child["COVERAGE_PROCESS_CONFIG"] == ("child-config" if explicit else "") + assert child["COVERAGE_PROCESS_START"] == "" + assert child["LITELLM_MASTER_KEY"] == gateway.key + assert os.environ["COVERAGE_PROCESS_CONFIG"] == "parent-config" + + def test_changed_archive_is_rejected(tmp_path: Path) -> None: archive: Final = tmp_path / "reference.tar.gz" archive.write_bytes(b"changed reference")