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(tests): Fix flaky container and scientific notation tests (#20650)
shin-bot-litellmdf299d31934e
diff --git a/tests/test_litellm/containers/test_container_api.py b/tests/test_litellm/containers/test_container_api.pyindex 9dcd9312ef3..38308f399d0 100644--- a/tests/test_litellm/containers/test_container_api.py+++ b/tests/test_litellm/containers/test_container_api.py@@ -2,7 +2,7 @@ import asyncioimport jsonimport osimport sys-from unittest.mock import MagicMock, patch+from unittest.mock import AsyncMock, MagicMock, patchimport httpximport pytest@@ -335,7 +335,14 @@ class TestContainerAPI:name="Test Container")- with patch.object(base_llm_http_handler, 'container_create_handler', return_value=mock_response):+ # Mock async_container_create_handler since router.acreate_container+ # uses _is_async=True which calls the async handler+ with patch.object(+ base_llm_http_handler,+ 'async_container_create_handler',+ new_callable=AsyncMock,+ return_value=mock_response+ ):result = await router.acreate_container(name="Test Container",custom_llm_provider="openai"diff --git a/tests/test_litellm/test_utils.py b/tests/test_litellm/test_utils.pyindex ee23811d5ac..71e043eb22a 100644--- a/tests/test_litellm/test_utils.py+++ b/tests/test_litellm/test_utils.py@@ -2283,18 +2283,14 @@ def test_register_model_with_scientific_notation():"""Test that the register_model function can handle scientific notation in the model name."""- # Use a unique model name to avoid conflicts with other tests- test_model_name = "test-scientific-notation-model-unique-12345"+ import uuid- # Clean up any pre-existing entry and clear caches- if test_model_name in litellm.model_cost:- del litellm.model_cost[test_model_name]+ # Use a truly unique model name with uuid to avoid conflicts when tests run in parallel+ test_model_name = f"test-scientific-notation-model-{uuid.uuid4().hex[:12]}"# Clear LRU caches that might have stale datafrom litellm.utils import (- _cached_get_model_info_helper,_invalidate_model_cost_lowercase_map,- get_model_info,)_invalidate_model_cost_lowercase_map()