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]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
Fix test_embedding_header_forwarding_with_model_group for parallel test execution
Julio Quinteros Pro7dcef86cc66d
diff --git a/tests/test_litellm/proxy/test_litellm_pre_call_utils.py b/tests/test_litellm/proxy/test_litellm_pre_call_utils.pyindex 25ae2ec825d..452db3902c0 100644--- a/tests/test_litellm/proxy/test_litellm_pre_call_utils.py+++ b/tests/test_litellm/proxy/test_litellm_pre_call_utils.py@@ -1347,9 +1347,18 @@ async def test_embedding_header_forwarding_with_model_group():This test verifies the fix for embedding endpoints not forwarding headerssimilar to how chat completion endpoints do."""- # Import the module that add_litellm_data_to_request uses to access litellm+ import importlib+import litellm.proxy.litellm_pre_call_utils as pre_call_utils_module+ # Reload the module to ensure it has a fresh reference to litellm+ # This is necessary because conftest.py reloads litellm at module scope,+ # which can cause the module's litellm reference to become stale+ importlib.reload(pre_call_utils_module)++ # Re-import the function after reload to get the fresh version+ from litellm.proxy.litellm_pre_call_utils import add_litellm_data_to_request+# Setup mock request for embeddingsrequest_mock = MagicMock(spec=Request)request_mock.url.path = "/v1/embeddings"@@ -1380,10 +1389,10 @@ async def test_embedding_header_forwarding_with_model_group():)# Mock model_group_settings to enable header forwarding for the model- # Use patch to ensure we modify the litellm reference that pre_call_utils actually uses+ # Use string-based patch to ensure we patch the current sys.modules['litellm']# This avoids issues with module reloading during parallel test executionmock_settings = MagicMock(forward_client_headers_to_llm_api=["local-openai/*"])- with patch.object(pre_call_utils_module.litellm, "model_group_settings", mock_settings):+ with patch("litellm.model_group_settings", mock_settings):# Call add_litellm_data_to_request which includes header forwarding logicupdated_data = await add_litellm_data_to_request(data=data,