mirror of
https://github.com/BerriAI/litellm.git
synced 2026-08-28 05:25:59 +00:00
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.
This commit is contained in:
parent
5cbe8353be
commit
ff4120863b
7 changed files with 10 additions and 10 deletions
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue