mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-25 05:54:53 +00:00
style(tests): swap the model_cost save/restore for monkeypatch.setattr
The test-quality gate (TQ005) counts direct litellm.<attr> = ... module- global mutations against a merge-base ceiling; monkeypatch.setattr restores the attribute at teardown without tripping the rule.
This commit is contained in:
parent
f594efe634
commit
a0bfdc85d3
1 changed files with 5 additions and 7 deletions
|
|
@ -22,15 +22,13 @@ from litellm.types.utils import (
|
|||
|
||||
@pytest.fixture(autouse=True)
|
||||
def _use_local_model_cost_map(monkeypatch):
|
||||
original_model_cost = litellm.model_cost
|
||||
monkeypatch.setenv("LITELLM_LOCAL_MODEL_COST_MAP", "True")
|
||||
litellm.model_cost = litellm.get_model_cost_map(url="")
|
||||
monkeypatch.setattr(
|
||||
litellm, "model_cost", litellm.get_model_cost_map(url="")
|
||||
)
|
||||
litellm.get_model_info.cache_clear()
|
||||
yield
|
||||
litellm.get_model_info.cache_clear()
|
||||
try:
|
||||
yield
|
||||
finally:
|
||||
litellm.model_cost = original_model_cost
|
||||
litellm.get_model_info.cache_clear()
|
||||
|
||||
|
||||
def _usage() -> ImageUsage:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue