Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

test: stabilize credentials CLI patch (#12305)

Ishaan Jaff4293dd2c2aec
diff --git a/tests/test_litellm/proxy/client/cli/test_credentials_commands.py b/tests/test_litellm/proxy/client/cli/test_credentials_commands.py
index 2295ad6f2d9..40a23948294 100644
--- a/tests/test_litellm/proxy/client/cli/test_credentials_commands.py
+++ b/tests/test_litellm/proxy/client/cli/test_credentials_commands.py
@@ -1,7 +1,7 @@
import json
import os
import sys
-from unittest.mock import MagicMock, patch
+from unittest.mock import MagicMock
import pytest
import requests
@@ -16,17 +16,18 @@ from litellm.proxy.client.cli.main import cli
@pytest.fixture
-def mock_credentials_client():
+def mock_credentials_client(monkeypatch):
"""Patch the CredentialsManagementClient used by the CLI commands."""
- with patch(
- "litellm.proxy.client.credentials.CredentialsManagementClient"
- ) as root_patch:
- # Ensure the reference used inside the CLI module also points to the mock
- with patch(
- "litellm.proxy.client.cli.commands.credentials.CredentialsManagementClient",
- root_patch,
- ) as cli_patch:
- yield cli_patch
+ mock_client = MagicMock()
+ monkeypatch.setattr(
+ "litellm.proxy.client.credentials.CredentialsManagementClient",
+ mock_client,
+ )
+ monkeypatch.setattr(
+ "litellm.proxy.client.cli.commands.credentials.CredentialsManagementClient",
+ mock_client,
+ )
+ return mock_client
@pytest.fixture