From 67a1482ee10e182c729ee56cc76a27f80856d817 Mon Sep 17 00:00:00 2001 From: ryan-crabbe-berri Date: Mon, 2 Nov 2026 22:50:53 -0800 Subject: [PATCH] test(cost_map): keep the exact fill-missing assertion for Claude thinking rules Build the expected baseline part from the loaded map so a rule that leaks an extra key into Claude entries still fails, and wrap lines over 120 characters. --- .../test_fallback_generalizations.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/tests/unit/litellm_core_utils/test_fallback_generalizations.py b/tests/unit/litellm_core_utils/test_fallback_generalizations.py index 77d94beef89..327031cfaf9 100644 --- a/tests/unit/litellm_core_utils/test_fallback_generalizations.py +++ b/tests/unit/litellm_core_utils/test_fallback_generalizations.py @@ -915,11 +915,12 @@ def test_shipped_claude_thinking_rules_backfill_only_anthropic(shipped_cost_map) assert info.get("supports_adaptive_thinking") is None assert info.get("supports_legacy_thinking") is None assert info.get("max_input_tokens") is None - assert match_fill_missing_generalizations("claude-sonnet-4-6", "anthropic").items() >= { + assert match_fill_missing_generalizations("claude-sonnet-4-6", "anthropic") == { + **_claude_baseline()["model_info"], "supports_adaptive_thinking": True, "supports_legacy_thinking": True, "supports_tool_search": True, - }.items() + } assert match_fill_missing_generalizations("claude-sonnet-4-6", "perplexity") is None @@ -964,7 +965,13 @@ def test_shipped_tool_search_rule_fills_mapped_claude_entries_without_flag(shipp assert match_fill_missing_generalizations("claude-opus-5", "perplexity") is None -CLAUDE_BASELINE_FILL_PROVIDERS: Final = ("anthropic", "azure_ai", "bedrock", "bedrock_converse", "vertex_ai-anthropic_models") +CLAUDE_BASELINE_FILL_PROVIDERS: Final = ( + "anthropic", + "azure_ai", + "bedrock", + "bedrock_converse", + "vertex_ai-anthropic_models", +) def _claude_baseline() -> Mapping[str, object]: @@ -989,7 +996,9 @@ def test_shipped_claude_baseline_fills_only_missing_keys_on_mapped_entries(shipp """A mapped Claude entry from a first-party host gets each baseline key it leaves out, while every baseline key the entry sets keeps the entry's own value.""" baseline: Final = _claude_baseline()["model_info"] - entries: Final = tuple((key, entry) for key, entry in _mapped_claude_chat_entries() if entry["litellm_provider"] == provider) + entries: Final = tuple( + (key, entry) for key, entry in _mapped_claude_chat_entries() if entry["litellm_provider"] == provider + ) assert any(baseline.keys() - entry.keys() for _, entry in entries) assert any(_fields_overriding_baseline(entry, baseline) for _, entry in entries)