From 35060bfbebf14ac460c5dd313c972cf7a158b7c8 Mon Sep 17 00:00:00 2001 From: Ishaan Jaffer Date: Sat, 21 Feb 2026 12:50:37 -0800 Subject: [PATCH] fix(tests): mock user_api_key_auth in test_vertex_passthrough_with_no_default_credentials vertex_proxy_route calls user_api_key_auth internally. When a prior test in the same xdist worker sets master_key, the auth check fails for the test request and create_pass_through_route is never called, causing assert_called_once_with to fail. Fix: patch user_api_key_auth as an AsyncMock in the with mock.patch() block. --- .../test_llm_pass_through_endpoints.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/test_litellm/proxy/pass_through_endpoints/test_llm_pass_through_endpoints.py b/tests/test_litellm/proxy/pass_through_endpoints/test_llm_pass_through_endpoints.py index a0953bf88c7..922c374418a 100644 --- a/tests/test_litellm/proxy/pass_through_endpoints/test_llm_pass_through_endpoints.py +++ b/tests/test_litellm/proxy/pass_through_endpoints/test_llm_pass_through_endpoints.py @@ -541,9 +541,13 @@ class TestVertexAIPassThroughHandler: "litellm.proxy.pass_through_endpoints.llm_passthrough_endpoints.vertex_llm_base._get_token_and_url" ) as mock_get_token, mock.patch( "litellm.proxy.pass_through_endpoints.llm_passthrough_endpoints.create_pass_through_route" - ) as mock_create_route: + ) as mock_create_route, mock.patch( + "litellm.proxy.pass_through_endpoints.llm_passthrough_endpoints.user_api_key_auth", + new_callable=AsyncMock, + ) as mock_auth: mock_ensure_token.return_value = ("test-auth-header", test_project) mock_get_token.return_value = (test_token, "") + mock_auth.return_value = MagicMock() # Call the route try: