From ad7b956e79b53a9e8d7a8f297747bc60880596f3 Mon Sep 17 00:00:00 2001 From: Daniel Dafoe Date: Wed, 26 Aug 2026 23:31:23 -0700 Subject: [PATCH] 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 --- .../openai_like/test_aquaduck_provider.py | 20 ++++++------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/tests/test_litellm/llms/openai_like/test_aquaduck_provider.py b/tests/test_litellm/llms/openai_like/test_aquaduck_provider.py index e65991d311a..169c0134cea 100644 --- a/tests/test_litellm/llms/openai_like/test_aquaduck_provider.py +++ b/tests/test_litellm/llms/openai_like/test_aquaduck_provider.py @@ -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):