mirror of
https://github.com/usestrix/strix.git
synced 2026-11-14 09:01:25 +00:00
test(pricing): clear the resolver cache after the patched registry assertions
The resolver's lru_cache is process-wide, so the mock-derived entries survived the patch and a later test resolving the same name could have read them instead of the real registry. Wrap the patched assertions in try/finally and clear the cache on the way out. Addresses review feedback on #1289.
This commit is contained in:
parent
e0623b5096
commit
397c002831
1 changed files with 11 additions and 6 deletions
|
|
@ -40,13 +40,18 @@ def test_prefers_native_provider_route_over_aggregators() -> None:
|
|||
"output_cost_per_token": 6e-06,
|
||||
},
|
||||
}
|
||||
with patch.object(litellm, "model_cost", model_cost):
|
||||
assert resolve_litellm_model("grok-4.5") == "xai/grok-4.5"
|
||||
try:
|
||||
with patch.object(litellm, "model_cost", model_cost):
|
||||
assert resolve_litellm_model("grok-4.5") == "xai/grok-4.5"
|
||||
|
||||
# An explicitly aggregator-qualified name still resolves to that aggregator.
|
||||
resolve_litellm_model.cache_clear()
|
||||
with patch.object(litellm, "model_cost", model_cost):
|
||||
assert resolve_litellm_model("x-ai/grok-4.5") == "openrouter/x-ai/grok-4.5"
|
||||
# An explicitly aggregator-qualified name still resolves to that aggregator.
|
||||
resolve_litellm_model.cache_clear()
|
||||
with patch.object(litellm, "model_cost", model_cost):
|
||||
assert resolve_litellm_model("x-ai/grok-4.5") == "openrouter/x-ai/grok-4.5"
|
||||
finally:
|
||||
# The resolver cache is process-wide: drop the mock-derived entries so a
|
||||
# later test cannot read them instead of consulting the real registry.
|
||||
resolve_litellm_model.cache_clear()
|
||||
|
||||
|
||||
def test_resolver_returns_none_for_unresolvable_model() -> None:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue