test: trim mcp fixture docstring and reload comment

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
Devin AI 2026-09-01 11:06:08 +00:00
parent 95c7ca8801
commit 5f44bdd1c1
2 changed files with 5 additions and 14 deletions

View file

@ -9,15 +9,8 @@ from litellm.proxy._experimental.mcp_server.mcp_server_manager import (
@pytest.fixture(autouse=True)
def _hermetic_mcp_server_registry():
"""Snapshot and restore the global manager's server-registry state around every test.
``global_mcp_server_manager`` is a module-global singleton, and many tests in this
package seed ``registry``/``config_mcp_servers`` (or clear them) without cleaning up.
In a shared CI shard the leaked entries poison later tests in the same worker, e.g.
the ``all_proxy_servers`` sentinel expansion in ``auth/`` suddenly sees a bridge
server registered by a discovery test, so the outcome depends on xdist scheduling.
Restoring the state here makes ordering irrelevant.
"""
"""Restore the singleton ``global_mcp_server_manager``'s registry state around every
test, so entries seeded by one test never leak into another on a shared shard."""
saved_registry = dict(global_mcp_server_manager.registry)
saved_config_servers = dict(global_mcp_server_manager.config_mcp_servers)
saved_tool_mapping = dict(global_mcp_server_manager.tool_name_to_mcp_server_name_mapping)

View file

@ -25,11 +25,9 @@ def _env_and_reload(**env):
saved = {key: os.environ.get(key) for key in env}
utils_module = importlib.import_module(UTILS_MODULE)
mgmt_module = importlib.import_module(MGMT_MODULE)
# Restore the pre-reload module attributes afterwards instead of reloading
# a third time: a reload re-creates every class in the module, so modules
# that imported names like MCPMissingUserEnvVarsError before this test
# would keep raising the old class while pytest.raises in later tests
# matches the new one
# Restore pre-reload module attributes afterwards instead of reloading again:
# a reload re-creates the module's classes, breaking exception identity for
# modules that imported them earlier
snapshots = {module: dict(vars(module)) for module in (utils_module, mgmt_module)}
def _apply_env(values):