From a7bafadd26726c6d83c8e8717ccf2d866fb36b62 Mon Sep 17 00:00:00 2001 From: yuneng-jiang Date: Thu, 22 Jan 2026 11:15:18 -0800 Subject: [PATCH] Fix non-root proxy tests --- tests/test_proxy_server_non_root.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) 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