From 4293dd2c2aecf37e11dc76fcee7a5321a1aa2016 Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Thu, 3 Jul 2025 18:09:32 -0700 Subject: [PATCH] test: stabilize credentials CLI patch (#12305) --- .../client/cli/test_credentials_commands.py | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) 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 2295ad6f2d..40a2394829 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