test(anthropic): force LITELLM_LOCAL_MODEL_COST_MAP for new max-effort tests

CI fetches model_prices_and_context_window.json from `main` at runtime,
so the new `supports_max_reasoning_effort` flags added in this PR are
not yet visible to the live CI run. Mirror the established pattern from
`tests/litellm_utils_tests/test_utils.py::test_supports_reasoning`:
set LITELLM_LOCAL_MODEL_COST_MAP=True and reload `litellm.model_cost`
inside each new accept-test, so they read the model-map version that is
in this same PR.

Affected tests:
* test_max_effort_accepted_for_opus_46
* test_max_effort_accepted_for_opus_47
* test_max_effort_accepted_for_sonnet_46

Locally verified: 137 / 137 pass in test_anthropic_chat_transformation.py
This commit is contained in:
shang309073819 2026-04-17 23:26:55 +00:00
parent 364a556062
commit 1625adcb0f

View file

@ -1653,9 +1653,7 @@ def test_max_effort_rejected_for_opus_45():
messages = [{"role": "user", "content": "Test"}]
with pytest.raises(
ValueError, match="effort='max' is not supported by this model"
):
with pytest.raises(ValueError, match="effort='max' is not supported by this model"):
optional_params = {"output_config": {"effort": "max"}}
config.transform_request(
model="claude-opus-4-5-20251101",
@ -2219,6 +2217,11 @@ def test_max_effort_accepted_for_sonnet_46():
> The ``max`` effort level is available on Claude Mythos Preview,
> Claude Opus 4.7, Claude Opus 4.6, and Claude Sonnet 4.6.
"""
import litellm
os.environ["LITELLM_LOCAL_MODEL_COST_MAP"] = "True"
litellm.model_cost = litellm.get_model_cost_map(url="")
config = AnthropicConfig()
messages = [{"role": "user", "content": "Test"}]
@ -2235,6 +2238,11 @@ def test_max_effort_accepted_for_sonnet_46():
def test_max_effort_accepted_for_opus_46():
"""Test that effort='max' works for Opus 4.6."""
import litellm
os.environ["LITELLM_LOCAL_MODEL_COST_MAP"] = "True"
litellm.model_cost = litellm.get_model_cost_map(url="")
config = AnthropicConfig()
messages = [{"role": "user", "content": "Test"}]
@ -2256,6 +2264,11 @@ def test_max_effort_accepted_for_opus_47():
``claude-opus-4-7-*`` models. The previous hardcoded ``_is_opus_4_6_model``
guard rejected the request before it ever reached Anthropic.
"""
import litellm
os.environ["LITELLM_LOCAL_MODEL_COST_MAP"] = "True"
litellm.model_cost = litellm.get_model_cost_map(url="")
config = AnthropicConfig()
messages = [{"role": "user", "content": "Test"}]