litellm/tests/e2e/mcp/conftest.py
ryan-crabbe-berri c943d650f4
test(e2e): tag router, batches and mcp tests with Subject metadata and record client steps (#44964)
* test(e2e): add enum values, auto-discovering label gates and secret hiding for e2e metadata

* test(e2e): tag router, batches and mcp tests with Subject metadata and record client steps

* test(e2e): leave the batches cleanup harness unit tests untagged

* docs(e2e): name every markerless harness test file that carries no Subject

* test(e2e): keep the step discovery comprehensions to one for clause

* test(e2e): name every driven model on the vllm batch, prompt caching and complexity router subjects
2026-10-07 10:32:58 -07:00

50 lines
1.7 KiB
Python

"""MCP suite's `client` fixture.
The shared lifecycle (resources/scoped_key), proxy liveness handling, and the
`e2e`/`covers` markers live in the parent tests/e2e/conftest.py. McpClient holds
the shared ProxyClient, so the `resources` fixture tears down whatever this suite
creates (keys via the ProxyClient, MCP servers via the deferred cleanups).
"""
from __future__ import annotations
import importlib.util
import sys
from pathlib import Path
from typing import Protocol, cast
import pytest
from datadog_mcp import DdLogsReader
from mcp_client import McpClient, build_client
from proxy_client import ProxyClient
class _DdLogsReaderBuilder(Protocol):
def __call__(self) -> DdLogsReader: ...
def _build_dd_logs_reader() -> DdLogsReader:
# Load logging/datadog_reader.py by path so basedpyright does not require a
# package layout. Register the module in sys.modules before exec so
# dataclasses inside it can resolve cls.__module__ (otherwise Python 3.12
# raises AttributeError: 'NoneType' object has no attribute '__dict__').
path = Path(__file__).resolve().parent.parent / "logging" / "datadog_reader.py"
name = "e2e_logging_datadog_reader"
spec = importlib.util.spec_from_file_location(name, path)
assert spec is not None and spec.loader is not None
module = importlib.util.module_from_spec(spec)
sys.modules[name] = module
spec.loader.exec_module(module)
builder = cast(_DdLogsReaderBuilder, getattr(module, "build_dd_logs_reader"))
return builder()
@pytest.fixture(scope="session")
def client(proxy: ProxyClient) -> McpClient:
return build_client(proxy)
@pytest.fixture(scope="session")
def dd_logs() -> DdLogsReader:
return _build_dd_logs_reader()