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:
Daniel Dafoe 2026-08-26 23:31:23 -07:00
parent a8f3304405
commit ad7b956e79

View file

@ -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):