From ff4120863b5ebced763695d954f35595c96989b9 Mon Sep 17 00:00:00 2001 From: Yuneng Jiang Date: Wed, 12 Aug 2026 11:15:54 -0700 Subject: [PATCH] test: rename tests that a later definition shadowed Python keeps only the last binding for a name, so when a file defines the same test twice the earlier one is unreachable. pytest cannot collect a function that no longer exists, so nothing reports it and the file still looks like it covers the scenario. These ten are cases where the two definitions have different bodies, meaning a real test was replaced rather than duplicated. Each is renamed to say what it actually covers, which makes it reachable again: - test_gemini_frequency_penalty: the dead copy checks the parameter is listed in get_supported_openai_params for vertex_ai; the survivor checks get_optional_params maps a value for gemini. Different function and different provider. - test_async_log_success_event_adds_to_queue and the failure variant: the dead copies run without mocking asyncio.create_task, so they exercise the real task path the survivors mock out. - test_async_send_batch_triggers_tasks: the dead copy asserts send is not awaited directly; the survivor asserts create_task was called. - test_model_id_in_required_metrics: the dead copy checks the model_id label on twelve further metrics the survivor dropped. - test_anthropic_messages_pt_file_block_preserves_cache_control: the dead copy passes model and llm_provider explicitly and uses real base64 PDF content. - test_translate_streaming_openai_chunk_to_anthropic_with_thinking: the dead copy covers thinking_delta; the survivor covers signature_delta. - test_client_initialization and test_client_without_api_key: the dead copies assert the resource clients are wired with the right base URL and key; the survivors only construct the object. - test_client_initialization_strips_trailing_slash: the dead copy constructs ModelsManagementClient directly rather than going through Client. Verification: collecting the seven touched files gives 401 node IDs before and 411 after, the ten new names and nothing else, with nothing lost. All ten pass. Running the touched files in full gives 299 passed, and test_optional_params.py goes from 111 passed to 112. Two further shadowed definitions were left alone rather than renamed: the dead copies of test_prompt_caching and test_cost_calculator_with_base_model_with_router have no assertions at all, one being a bare pass and the other a lone import, so restoring them would add tests that cannot fail. --- tests/llm_translation/test_optional_params.py | 2 +- tests/logging_callback_tests/test_sqs_logger.py | 6 +++--- tests/test_litellm/integrations/test_prometheus_labels.py | 2 +- .../test_litellm_core_utils_prompt_templates_factory.py | 2 +- ...pic_experimental_pass_through_adapters_transformation.py | 2 +- tests/test_litellm/proxy/client/test_client.py | 4 ++-- tests/test_litellm/proxy/client/test_models.py | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/llm_translation/test_optional_params.py b/tests/llm_translation/test_optional_params.py index 9ebdb4b7e97..814f5a235e1 100644 --- a/tests/llm_translation/test_optional_params.py +++ b/tests/llm_translation/test_optional_params.py @@ -1137,7 +1137,7 @@ def test_ollama_pydantic_obj(): ) -def test_gemini_frequency_penalty(): +def test_gemini_frequency_penalty_listed_in_vertex_ai_supported_params(): from litellm.utils import get_supported_openai_params optional_params = get_supported_openai_params( diff --git a/tests/logging_callback_tests/test_sqs_logger.py b/tests/logging_callback_tests/test_sqs_logger.py index 83692af3bc0..913d617518e 100644 --- a/tests/logging_callback_tests/test_sqs_logger.py +++ b/tests/logging_callback_tests/test_sqs_logger.py @@ -151,7 +151,7 @@ async def test_async_sqs_logger_error_flush(): @pytest.mark.asyncio -async def test_async_log_success_event_adds_to_queue(monkeypatch): +async def test_async_log_success_event_adds_to_queue_with_real_create_task(monkeypatch): monkeypatch.setattr("litellm.aws_sqs_callback_params", {}) logger = SQSLogger(sqs_queue_url="https://example.com", sqs_region_name="us-west-2") @@ -163,7 +163,7 @@ async def test_async_log_success_event_adds_to_queue(monkeypatch): @pytest.mark.asyncio -async def test_async_log_failure_event_adds_to_queue(monkeypatch): +async def test_async_log_failure_event_adds_to_queue_with_real_create_task(monkeypatch): monkeypatch.setattr("litellm.aws_sqs_callback_params", {}) logger = SQSLogger(sqs_queue_url="https://example.com", sqs_region_name="us-west-2") @@ -180,7 +180,7 @@ async def test_async_log_failure_event_adds_to_queue(monkeypatch): @pytest.mark.asyncio -async def test_async_send_batch_triggers_tasks(monkeypatch): +async def test_async_send_batch_does_not_await_send_directly(monkeypatch): monkeypatch.setattr("litellm.aws_sqs_callback_params", {}) logger = SQSLogger(sqs_queue_url="https://example.com", sqs_region_name="us-west-2") logger.async_send_message = AsyncMock() diff --git a/tests/test_litellm/integrations/test_prometheus_labels.py b/tests/test_litellm/integrations/test_prometheus_labels.py index a7d6e163eaf..859cdd30c11 100644 --- a/tests/test_litellm/integrations/test_prometheus_labels.py +++ b/tests/test_litellm/integrations/test_prometheus_labels.py @@ -61,7 +61,7 @@ def test_user_email_in_required_metrics(): print(f"✅ {metric_name} contains user_email label") -def test_model_id_in_required_metrics(): +def test_model_id_in_extended_metric_set(): """ Test that model_id label is present in all the metrics that should have it """ diff --git a/tests/test_litellm/litellm_core_utils/prompt_templates/test_litellm_core_utils_prompt_templates_factory.py b/tests/test_litellm/litellm_core_utils/prompt_templates/test_litellm_core_utils_prompt_templates_factory.py index 8edc6a91cbf..de5d0a180c6 100644 --- a/tests/test_litellm/litellm_core_utils/prompt_templates/test_litellm_core_utils_prompt_templates_factory.py +++ b/tests/test_litellm/litellm_core_utils/prompt_templates/test_litellm_core_utils_prompt_templates_factory.py @@ -2077,7 +2077,7 @@ def test_bedrock_tools_unpack_defs_no_oom_with_nested_refs(): assert "$defs" not in tool_schema, "$defs should be removed after expansion" -def test_anthropic_messages_pt_file_block_preserves_cache_control(): +def test_anthropic_messages_pt_file_block_cache_control_with_explicit_provider(): """ Test that cache_control on file-type content blocks is preserved when translating to Anthropic message format. diff --git a/tests/test_litellm/llms/anthropic/experimental_pass_through/adapters/test_anthropic_experimental_pass_through_adapters_transformation.py b/tests/test_litellm/llms/anthropic/experimental_pass_through/adapters/test_anthropic_experimental_pass_through_adapters_transformation.py index 413a9808ed0..fe6adade6a8 100644 --- a/tests/test_litellm/llms/anthropic/experimental_pass_through/adapters/test_anthropic_experimental_pass_through_adapters_transformation.py +++ b/tests/test_litellm/llms/anthropic/experimental_pass_through/adapters/test_anthropic_experimental_pass_through_adapters_transformation.py @@ -877,7 +877,7 @@ def test_translate_openai_content_to_anthropic_thinking_and_redacted_thinking(): assert result[1]["data"] == "REDACTED" -def test_translate_streaming_openai_chunk_to_anthropic_with_thinking(): +def test_translate_streaming_openai_chunk_to_anthropic_thinking_delta(): choices = [ StreamingChoices( finish_reason=None, diff --git a/tests/test_litellm/proxy/client/test_client.py b/tests/test_litellm/proxy/client/test_client.py index c97094802ce..b0e458da89e 100644 --- a/tests/test_litellm/proxy/client/test_client.py +++ b/tests/test_litellm/proxy/client/test_client.py @@ -22,7 +22,7 @@ def api_key(): return "test-api-key" -def test_client_initialization(base_url, api_key): +def test_client_initialization_wires_resource_clients(base_url, api_key): """Test that the Client is properly initialized with all resource clients""" client = Client(base_url=base_url, api_key=api_key) @@ -63,7 +63,7 @@ def test_client_initialization_strips_trailing_slash(): assert client.http._base_url == "http://localhost:8000" -def test_client_without_api_key(base_url): +def test_client_without_api_key_propagates_none_to_resource_clients(base_url): """Test that the client works without an API key""" client = Client(base_url=base_url) diff --git a/tests/test_litellm/proxy/client/test_models.py b/tests/test_litellm/proxy/client/test_models.py index 6d30f693568..b2485032a37 100644 --- a/tests/test_litellm/proxy/client/test_models.py +++ b/tests/test_litellm/proxy/client/test_models.py @@ -143,7 +143,7 @@ def test_list_invalid_api_keys(base_url, api_key): assert "Authorization" not in request.headers -def test_client_initialization_strips_trailing_slash(): +def test_models_client_initialization_strips_trailing_slash(): """Test that the client properly strips trailing slashes from base_url during initialization""" client = ModelsManagementClient(base_url="http://localhost:8000/////") assert client._base_url == "http://localhost:8000"