Skip to content

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]

test: give cost-map guard next() a default so a renamed rule fails with a clear assertion

mateo-berri8b1a19fb0254
diff --git a/tests/test_litellm/llms/azure_ai/claude/test_azure_anthropic_messages_transformation.py b/tests/test_litellm/llms/azure_ai/claude/test_azure_anthropic_messages_transformation.py
index 00d8625896a..25d24cfc3ac 100644
--- a/tests/test_litellm/llms/azure_ai/claude/test_azure_anthropic_messages_transformation.py
+++ b/tests/test_litellm/llms/azure_ai/claude/test_azure_anthropic_messages_transformation.py
@@ -7,7 +7,7 @@ sys.path.insert(
0, os.path.abspath(os.path.join(os.path.dirname(__file__), "../../../../.."))
)
-from unittest.mock import MagicMock, patch
+from unittest.mock import patch
import pytest
@@ -479,10 +479,12 @@ def test_azure_claude_4_8_plus_cost_map_entries_carry_mid_conversation_system_fl
with open(cost_map_path) as f:
cost_map = json.load(f)
rules = cost_map["fallback_generalizations"]["rules"]
- pattern = re.compile(
- next(r["pattern"] for r in rules if r["name"] == "claude-mid-conversation-system"),
- re.IGNORECASE,
+ rule_pattern = next(
+ (r["pattern"] for r in rules if r["name"] == "claude-mid-conversation-system"),
+ None,
)
+ assert rule_pattern is not None, "claude-mid-conversation-system rule not found in fallback_generalizations"
+ pattern = re.compile(rule_pattern, re.IGNORECASE)
missing = [
key
for key, info in cost_map.items()
diff --git a/tests/test_litellm/llms/vertex_ai/vertex_ai_partner_models/anthropic/test_vertex_ai_partner_models_anthropic_messages_config.py b/tests/test_litellm/llms/vertex_ai/vertex_ai_partner_models/anthropic/test_vertex_ai_partner_models_anthropic_messages_config.py
index f20cc6af6b1..2d09cc0ed32 100644
--- a/tests/test_litellm/llms/vertex_ai/vertex_ai_partner_models/anthropic/test_vertex_ai_partner_models_anthropic_messages_config.py
+++ b/tests/test_litellm/llms/vertex_ai/vertex_ai_partner_models/anthropic/test_vertex_ai_partner_models_anthropic_messages_config.py
@@ -658,10 +658,12 @@ def test_vertex_claude_4_8_plus_cost_map_entries_carry_mid_conversation_system_f
with open(cost_map_path) as f:
cost_map = json.load(f)
rules = cost_map["fallback_generalizations"]["rules"]
- pattern = re.compile(
- next(r["pattern"] for r in rules if r["name"] == "claude-mid-conversation-system"),
- re.IGNORECASE,
+ rule_pattern = next(
+ (r["pattern"] for r in rules if r["name"] == "claude-mid-conversation-system"),
+ None,
)
+ assert rule_pattern is not None, "claude-mid-conversation-system rule not found in fallback_generalizations"
+ pattern = re.compile(rule_pattern, re.IGNORECASE)
missing = [
key
for key, info in cost_map.items()