diff --git a/tests/test_litellm/proxy/spend_tracking/test_spend_management_endpoints.py b/tests/test_litellm/proxy/spend_tracking/test_spend_management_endpoints.py index 97d1d4a2f38..5ca10df9f89 100644 --- a/tests/test_litellm/proxy/spend_tracking/test_spend_management_endpoints.py +++ b/tests/test_litellm/proxy/spend_tracking/test_spend_management_endpoints.py @@ -1231,9 +1231,12 @@ async def _wait_for_mock_call(mock, timeout=10, interval=0.1): class TestSpendLogsPayload: def setup_method(self): self._original_callbacks = litellm.callbacks[:] + self._original_cache = litellm.cache + litellm.cache = None def teardown_method(self): litellm.callbacks = self._original_callbacks + litellm.cache = self._original_cache @pytest.mark.asyncio async def test_spend_logs_payload_e2e(self): diff --git a/tests/test_litellm/proxy/test_proxy_cli.py b/tests/test_litellm/proxy/test_proxy_cli.py index e8a60e595ca..236080aab7e 100644 --- a/tests/test_litellm/proxy/test_proxy_cli.py +++ b/tests/test_litellm/proxy/test_proxy_cli.py @@ -586,9 +586,6 @@ class TestHealthAppFactory: @patch("litellm.proxy.db.prisma_client.PrismaManager.setup_database") @patch("litellm.proxy.db.check_migration.check_prisma_schema_diff") @patch("litellm.proxy.db.prisma_client.should_update_prisma_schema") - @patch.dict( - os.environ, {"DATABASE_URL": "postgresql://test:test@localhost:5432/test"} - ) def test_use_prisma_db_push_flag_behavior( self, mock_should_update_schema, @@ -616,7 +613,19 @@ class TestHealthAppFactory: save_worker_config=MagicMock(), ) + # Strip DIRECT_URL and set DATABASE_URL to a test value so Click's + # CliRunner doesn't encounter real DB env vars (causes stream lifecycle + # issues with Click 8.3.x in CI environments). + clean_env = { + k: v + for k, v in os.environ.items() + if k not in ("DATABASE_URL", "DIRECT_URL") + } + clean_env["DATABASE_URL"] = "postgresql://test:test@localhost:5432/test" + with patch.dict( + os.environ, clean_env, clear=True + ), patch.dict( "sys.modules", { "proxy_server": mock_proxy_module,