From 2351aaba74e5c25328fe7a709bf07f052e102a9d Mon Sep 17 00:00:00 2001 From: shivam Date: Tue, 28 Jul 2026 00:07:25 +0000 Subject: [PATCH] test(anthropic cost): scope local cost-map env flag with monkeypatch Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- tests/test_litellm/test_cost_calculator.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test_litellm/test_cost_calculator.py b/tests/test_litellm/test_cost_calculator.py index 16f69773151..26ba485d796 100644 --- a/tests/test_litellm/test_cost_calculator.py +++ b/tests/test_litellm/test_cost_calculator.py @@ -2742,7 +2742,7 @@ def _register_anthropic_geo_cache_model(model: str) -> None: ) -def test_anthropic_geo_multiplier_applies_to_cache_tokens(): +def test_anthropic_geo_multiplier_applies_to_cache_tokens(monkeypatch): """ Regression: the regional (geo) uplift must scale cache read and cache write cost too, not just non-cache input and output. @@ -2757,7 +2757,7 @@ def test_anthropic_geo_multiplier_applies_to_cache_tokens(): ) from litellm.types.utils import PromptTokensDetailsWrapper, Usage - os.environ["LITELLM_LOCAL_MODEL_COST_MAP"] = "True" + monkeypatch.setenv("LITELLM_LOCAL_MODEL_COST_MAP", "True") litellm.model_cost = litellm.get_model_cost_map(url="") model = "claude-test-geo-cache-model" @@ -2787,7 +2787,7 @@ def test_anthropic_geo_multiplier_applies_to_cache_tokens(): assert geo_completion_cost == pytest.approx(base_completion_cost * 1.1) -def test_anthropic_geo_and_fast_multipliers_compose(): +def test_anthropic_geo_and_fast_multipliers_compose(monkeypatch): """ The ``fast`` speed multiplier stays cache-exclusive (the old explicit ``fast/`` entries kept base cache rates) while the geo multiplier scales the @@ -2799,7 +2799,7 @@ def test_anthropic_geo_and_fast_multipliers_compose(): ) from litellm.types.utils import PromptTokensDetailsWrapper, Usage - os.environ["LITELLM_LOCAL_MODEL_COST_MAP"] = "True" + monkeypatch.setenv("LITELLM_LOCAL_MODEL_COST_MAP", "True") litellm.model_cost = litellm.get_model_cost_map(url="") model = "claude-test-geo-fast-cache-model"