mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-06 08:16:43 +00:00
fix(aquaduck): use monkeypatch for model_cost in tests
Direct litellm.model_cost assignment tripped TQ005 in CI. Switch the fixtures to monkeypatch.setattr so the global is restored automatically. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
a8f3304405
commit
ad7b956e79
1 changed files with 6 additions and 14 deletions
|
|
@ -144,15 +144,11 @@ class TestAquaduckCostTracking:
|
|||
|
||||
@pytest.fixture(autouse=True)
|
||||
def _use_local_model_cost_map(self, monkeypatch: pytest.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()
|
||||
|
||||
@staticmethod
|
||||
def _load(path_parts):
|
||||
|
|
@ -221,15 +217,11 @@ class TestAquaduckCostTracking:
|
|||
class TestAquaduckRouting:
|
||||
@pytest.fixture(autouse=True)
|
||||
def _use_local_model_cost_map(self, monkeypatch: pytest.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()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_router_spend_is_attributed_to_aquaduck_pricing(self):
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue