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]

Fix non-root proxy tests

yuneng-jianga7bafadd2672
diff --git a/tests/test_proxy_server_non_root.py b/tests/test_proxy_server_non_root.py
index b632e922929..53cdf5588fa 100644
--- a/tests/test_proxy_server_non_root.py
+++ b/tests/test_proxy_server_non_root.py
@@ -17,8 +17,13 @@ def test_restructure_ui_html_files_skipped_in_non_root(monkeypatch):
ui_path = "/var/lib/litellm/ui"
# Mock the _restructure_ui_html_files function to check if it's called
+ # Use create=True to allow patching even if the module hasn't been imported yet
+ # or if the function doesn't exist (it's defined inside a try/except block)
+ # spec=False prevents spec checking which can fail during import resolution
with patch(
- "litellm.proxy.proxy_server._restructure_ui_html_files"
+ "litellm.proxy.proxy_server._restructure_ui_html_files",
+ create=True,
+ spec=False,
) as mock_restructure:
# Simulate the logic we added in proxy_server.py
if is_non_root and ui_path == "/var/lib/litellm/ui":
@@ -40,8 +45,13 @@ def test_restructure_ui_html_files_NOT_skipped_locally(monkeypatch):
is_non_root = False
ui_path = "/some/local/path"
+ # Use create=True and spec=False to allow patching even if the module hasn't been imported yet
+ # or if the function doesn't exist (it's defined inside a try/except block)
+ # spec=False prevents spec checking which can fail during import resolution
with patch(
- "litellm.proxy.proxy_server._restructure_ui_html_files"
+ "litellm.proxy.proxy_server._restructure_ui_html_files",
+ create=True,
+ spec=False,
) as mock_restructure:
if is_non_root and ui_path == "/var/lib/litellm/ui":
pass