test(anthropic cost): scope local cost-map env flag with monkeypatch
Some checks failed
LiteLLM Rust / rustfmt, clippy, test (push) Has been cancelled
Terraform Provider / gofmt, vet, build, test (push) Has been cancelled
Terraform Provider / Provider endpoints vs proxy OpenAPI schema (push) Has been cancelled

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
shivam 2026-07-28 00:07:25 +00:00 • committed by Devin AI
parent dc58c35bba
commit 2351aaba74

View file

@ -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"