From 782ba9f5a0030ea2bc76bbf89536bb5d513455fd Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Thu, 3 Jul 2025 15:58:49 -0700 Subject: [PATCH] sys.path.insert for cli tests --- .../test_litellm/proxy/client/cli/test_auth_commands.py | 6 ++++++ .../test_litellm/proxy/client/cli/test_chat_commands.py | 7 +++++++ .../proxy/client/cli/test_credentials_commands.py | 7 +++++++ .../test_litellm/proxy/client/cli/test_global_options.py | 6 ++++++ .../proxy/client/cli/test_models_commands.py | 6 ++++++ .../test_litellm/proxy/client/cli/test_users_commands.py | 7 +++++++ tests/test_litellm/proxy/client/test_chat.py | 8 ++++++++ tests/test_litellm/proxy/client/test_client.py | 7 +++++++ tests/test_litellm/proxy/client/test_credentials.py | 8 ++++++++ tests/test_litellm/proxy/client/test_http_client.py | 7 +++++++ tests/test_litellm/proxy/client/test_http_commands.py | 7 +++++++ tests/test_litellm/proxy/client/test_keys.py | 8 ++++++++ tests/test_litellm/proxy/client/test_model_groups.py | 8 ++++++++ tests/test_litellm/proxy/client/test_models.py | 9 +++++++++ tests/test_litellm/proxy/client/test_users.py | 7 +++++++ 15 files changed, 108 insertions(+) diff --git a/tests/test_litellm/proxy/client/cli/test_auth_commands.py b/tests/test_litellm/proxy/client/cli/test_auth_commands.py index 33e5ba29bf..611fde7767 100644 --- a/tests/test_litellm/proxy/client/cli/test_auth_commands.py +++ b/tests/test_litellm/proxy/client/cli/test_auth_commands.py @@ -1,10 +1,16 @@ import json import os +import sys import tempfile import time from pathlib import Path from unittest.mock import MagicMock, Mock, mock_open, patch +sys.path.insert( + 0, os.path.abspath("../../..") +) # Adds the parent directory to the system path + + import pytest from click.testing import CliRunner diff --git a/tests/test_litellm/proxy/client/cli/test_chat_commands.py b/tests/test_litellm/proxy/client/cli/test_chat_commands.py index 0b785f4962..1226c3557f 100644 --- a/tests/test_litellm/proxy/client/cli/test_chat_commands.py +++ b/tests/test_litellm/proxy/client/cli/test_chat_commands.py @@ -1,10 +1,17 @@ import json +import os +import sys from unittest.mock import MagicMock, patch import pytest import requests from click.testing import CliRunner +sys.path.insert( + 0, os.path.abspath("../../..") +) # Adds the parent directory to the system path + + from litellm.proxy.client.cli.main import cli 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 cae9e79d79..9ad2bd067f 100644 --- a/tests/test_litellm/proxy/client/cli/test_credentials_commands.py +++ b/tests/test_litellm/proxy/client/cli/test_credentials_commands.py @@ -1,10 +1,17 @@ import json +import os +import sys from unittest.mock import MagicMock, patch import pytest import requests from click.testing import CliRunner +sys.path.insert( + 0, os.path.abspath("../../..") +) # Adds the parent directory to the system path + + from litellm.proxy.client.cli.main import cli diff --git a/tests/test_litellm/proxy/client/cli/test_global_options.py b/tests/test_litellm/proxy/client/cli/test_global_options.py index b14bfdf92a..980556893a 100644 --- a/tests/test_litellm/proxy/client/cli/test_global_options.py +++ b/tests/test_litellm/proxy/client/cli/test_global_options.py @@ -1,10 +1,16 @@ # stdlib imports import os +import sys from unittest.mock import patch import pytest from click.testing import CliRunner +sys.path.insert( + 0, os.path.abspath("../../..") +) # Adds the parent directory to the system path + + from litellm._version import version as litellm_version from litellm.proxy.client.cli import cli diff --git a/tests/test_litellm/proxy/client/cli/test_models_commands.py b/tests/test_litellm/proxy/client/cli/test_models_commands.py index 16744f4a89..7f47d14656 100644 --- a/tests/test_litellm/proxy/client/cli/test_models_commands.py +++ b/tests/test_litellm/proxy/client/cli/test_models_commands.py @@ -1,6 +1,7 @@ # stdlib imports import json import os +import sys import time from unittest.mock import patch @@ -9,6 +10,11 @@ import pytest # third party imports from click.testing import CliRunner +sys.path.insert( + 0, os.path.abspath("../../..") +) # Adds the parent directory to the system path + + # local imports from litellm.proxy.client.cli import cli from litellm.proxy.client.cli.commands.models import ( diff --git a/tests/test_litellm/proxy/client/cli/test_users_commands.py b/tests/test_litellm/proxy/client/cli/test_users_commands.py index 9b291c4ec9..f18ceb30c2 100644 --- a/tests/test_litellm/proxy/client/cli/test_users_commands.py +++ b/tests/test_litellm/proxy/client/cli/test_users_commands.py @@ -1,8 +1,15 @@ +import os +import sys from unittest.mock import patch import pytest from click.testing import CliRunner +sys.path.insert( + 0, os.path.abspath("../../..") +) # Adds the parent directory to the system path + + from litellm.proxy.client.cli import cli diff --git a/tests/test_litellm/proxy/client/test_chat.py b/tests/test_litellm/proxy/client/test_chat.py index 2fd5a4a26f..332edc7857 100644 --- a/tests/test_litellm/proxy/client/test_chat.py +++ b/tests/test_litellm/proxy/client/test_chat.py @@ -1,6 +1,14 @@ +import os +import sys + import pytest import requests +sys.path.insert( + 0, os.path.abspath("../../..") +) # Adds the parent directory to the system path + + from litellm.proxy.client.chat import ChatClient from litellm.proxy.client.exceptions import UnauthorizedError diff --git a/tests/test_litellm/proxy/client/test_client.py b/tests/test_litellm/proxy/client/test_client.py index 267e9f074a..c97094802c 100644 --- a/tests/test_litellm/proxy/client/test_client.py +++ b/tests/test_litellm/proxy/client/test_client.py @@ -1,5 +1,12 @@ +import os +import sys + import pytest +sys.path.insert( + 0, os.path.abspath("../../..") +) # Adds the parent directory to the system path + from litellm.proxy.client import ChatClient, Client, ModelsManagementClient from litellm.proxy.client.http_client import HTTPClient from litellm.proxy.client.keys import KeysManagementClient diff --git a/tests/test_litellm/proxy/client/test_credentials.py b/tests/test_litellm/proxy/client/test_credentials.py index ef0cc9998c..a83e1cf0cd 100644 --- a/tests/test_litellm/proxy/client/test_credentials.py +++ b/tests/test_litellm/proxy/client/test_credentials.py @@ -1,6 +1,14 @@ +import os +import sys + import pytest import requests +sys.path.insert( + 0, os.path.abspath("../../..") +) # Adds the parent directory to the system path + + from litellm.proxy.client.credentials import CredentialsManagementClient from litellm.proxy.client.exceptions import UnauthorizedError diff --git a/tests/test_litellm/proxy/client/test_http_client.py b/tests/test_litellm/proxy/client/test_http_client.py index 30bb1489c5..3bb6c4cef8 100644 --- a/tests/test_litellm/proxy/client/test_http_client.py +++ b/tests/test_litellm/proxy/client/test_http_client.py @@ -1,11 +1,18 @@ """Tests for the HTTP client.""" import json +import os +import sys import pytest import requests import responses +sys.path.insert( + 0, os.path.abspath("../../..") +) # Adds the parent directory to the system path + + from litellm.proxy.client.http_client import HTTPClient diff --git a/tests/test_litellm/proxy/client/test_http_commands.py b/tests/test_litellm/proxy/client/test_http_commands.py index f305efb335..d1dea3a554 100644 --- a/tests/test_litellm/proxy/client/test_http_commands.py +++ b/tests/test_litellm/proxy/client/test_http_commands.py @@ -1,11 +1,18 @@ """Tests for the HTTP command group.""" import json +import os +import sys import pytest import responses from click.testing import CliRunner +sys.path.insert( + 0, os.path.abspath("../../..") +) # Adds the parent directory to the system path + + from litellm.proxy.client.cli.commands.http import http diff --git a/tests/test_litellm/proxy/client/test_keys.py b/tests/test_litellm/proxy/client/test_keys.py index 7ce4452bdc..4e341e8ea7 100644 --- a/tests/test_litellm/proxy/client/test_keys.py +++ b/tests/test_litellm/proxy/client/test_keys.py @@ -1,6 +1,14 @@ +import os +import sys + import pytest import requests +sys.path.insert( + 0, os.path.abspath("../../..") +) # Adds the parent directory to the system path + + from litellm.proxy.client.exceptions import UnauthorizedError from litellm.proxy.client.keys import KeysManagementClient diff --git a/tests/test_litellm/proxy/client/test_model_groups.py b/tests/test_litellm/proxy/client/test_model_groups.py index 0afb253149..4642d96170 100644 --- a/tests/test_litellm/proxy/client/test_model_groups.py +++ b/tests/test_litellm/proxy/client/test_model_groups.py @@ -1,6 +1,14 @@ +import os +import sys + import pytest import requests +sys.path.insert( + 0, os.path.abspath("../../..") +) # Adds the parent directory to the system path + + from litellm.proxy.client import Client, ModelGroupsManagementClient from litellm.proxy.client.exceptions import UnauthorizedError diff --git a/tests/test_litellm/proxy/client/test_models.py b/tests/test_litellm/proxy/client/test_models.py index afd042682b..1f991d3a1c 100644 --- a/tests/test_litellm/proxy/client/test_models.py +++ b/tests/test_litellm/proxy/client/test_models.py @@ -1,6 +1,15 @@ +import os +import sys + import pytest import requests +sys.path.insert( + 0, os.path.abspath("../../..") +) # Adds the parent directory to the system path + + + from litellm.proxy.client import Client, ModelsManagementClient from litellm.proxy.client.exceptions import NotFoundError, UnauthorizedError diff --git a/tests/test_litellm/proxy/client/test_users.py b/tests/test_litellm/proxy/client/test_users.py index 5bcd783b91..a48cf8f791 100644 --- a/tests/test_litellm/proxy/client/test_users.py +++ b/tests/test_litellm/proxy/client/test_users.py @@ -1,7 +1,14 @@ +import os +import sys from unittest.mock import MagicMock, patch import pytest +sys.path.insert( + 0, os.path.abspath("../../..") +) # Adds the parent directory to the system path + + from litellm.proxy.client.users import ( NotFoundError, UnauthorizedError,