From b2567531f709d5fd53283135f6aea714246c0bfe Mon Sep 17 00:00:00 2001 From: Bharat Lakhiyani Date: Sat, 25 Jul 2026 00:06:31 -0400 Subject: [PATCH] test(bedrock): clear all model-cost LRU caches in local_cost_map fixture get_model_info.cache_clear() alone leaves _cached_get_model_info_helper (used by completion_cost) holding entries from whichever cost map was active first, making the cost-tracking test order-dependent. Use _invalidate_model_cost_lowercase_map, which clears both caches and the lowercase lookup map. --- tests/test_litellm/llms/bedrock/test_mantle.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/test_litellm/llms/bedrock/test_mantle.py b/tests/test_litellm/llms/bedrock/test_mantle.py index cce00a01a9d..c219cc8a47d 100644 --- a/tests/test_litellm/llms/bedrock/test_mantle.py +++ b/tests/test_litellm/llms/bedrock/test_mantle.py @@ -692,16 +692,17 @@ async def test_mantle_anthropic_messages_streaming_sends_stream_and_passes_throu @pytest.fixture def local_cost_map(monkeypatch): import litellm + from litellm.utils import _invalidate_model_cost_lowercase_map original_model_cost = litellm.model_cost try: monkeypatch.setenv("LITELLM_LOCAL_MODEL_COST_MAP", "true") litellm.model_cost = litellm.get_model_cost_map(url="") - litellm.get_model_info.cache_clear() + _invalidate_model_cost_lowercase_map() yield finally: litellm.model_cost = original_model_cost - litellm.get_model_info.cache_clear() + _invalidate_model_cost_lowercase_map() @pytest.mark.parametrize(