Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

test(proxy): set the unsafe-proxy override at the remaining test boot sites and isolate the boot test from a leaked scheduler

ryan-crabbe-berri3c9c860de7ac
diff --git a/tests/mcp_tests/test_proxy_mcp_e2e.py b/tests/mcp_tests/test_proxy_mcp_e2e.py
index 99c03b3438d..9e3e421b4dd 100644
--- a/tests/mcp_tests/test_proxy_mcp_e2e.py
+++ b/tests/mcp_tests/test_proxy_mcp_e2e.py
@@ -54,6 +54,7 @@ def _clear_proxy_database_env() -> typing.Iterator[None]:
# the LITELLM_MASTER_KEY env var, overriding whatever initialize() set from
# the config file. We must set it here so the lifespan doesn't reset it to None.
mp.setenv("LITELLM_MASTER_KEY", "sk-1234")
+ mp.setenv("LITELLM_DANGEROUSLY_ALLOW_UNSAFE_PROXY", "true")
try:
yield
finally:
diff --git a/tests/test_litellm/proxy/conftest.py b/tests/test_litellm/proxy/conftest.py
index 65e12b7d777..b31d2229466 100644
--- a/tests/test_litellm/proxy/conftest.py
+++ b/tests/test_litellm/proxy/conftest.py
@@ -268,6 +268,7 @@ def create_proxy_test_client(
# Set environment variables
set_proxy_environment_variables(monkeypatch, database_url=database_url)
+ monkeypatch.setenv("LITELLM_DANGEROUSLY_ALLOW_UNSAFE_PROXY", "true")
# Initialize proxy
asyncio.run(initialize(config=config_fp, debug=init_options.get("debug", False)))
diff --git a/tests/test_litellm/proxy/test_proxy_server.py b/tests/test_litellm/proxy/test_proxy_server.py
index 07a07a25764..a670f467619 100644
--- a/tests/test_litellm/proxy/test_proxy_server.py
+++ b/tests/test_litellm/proxy/test_proxy_server.py
@@ -1636,6 +1636,8 @@ def _boot_with_general_settings(monkeypatch, tmp_path, general_settings):
for name in ("LITELLM_MASTER_KEY", "LITELLM_DANGEROUSLY_ALLOW_UNSAFE_PROXY", "WORKER_CONFIG", "DATABASE_URL"):
monkeypatch.delenv(name, raising=False)
monkeypatch.setenv("CONFIG_FILE_PATH", str(config_path))
+ scheduler_left_on_a_closed_event_loop_by_an_earlier_test = "litellm.proxy.proxy_server.scheduler"
+ monkeypatch.setattr(scheduler_left_on_a_closed_event_loop_by_an_earlier_test, None)
announced = []
monkeypatch.setattr("litellm.proxy.proxy_server.announce_on_stderr_at_exit", announced.append)
return config_path, announced