fix: Implement reviewer suggestions for test improvements and version constraints

Co-Authored-By: Joe Moura <joao@crewai.com>
This commit is contained in:
Devin AI
2025-04-03 17:35:00 +00:00
parent 764e1b8a51
commit bd817290c2
2 changed files with 72 additions and 36 deletions

View File

@@ -11,7 +11,7 @@ dependencies = [
# Core Dependencies
"pydantic>=2.4.2",
"openai>=1.13.3",
"litellm>=1.65.1",
"litellm>=1.65.1,<2.0.0",
"instructor>=1.3.3",
# Text Processing
"pdfplumber>=0.11.4",

View File

@@ -1,24 +1,62 @@
"""
Dependency Compatibility Tests
Tests to verify compatibility between litellm and other packages that depend on httpx.
Known working versions:
- httpx >= 0.28.1
- litellm >= 1.65.1
- exa-py (optional)
- google-genai (optional)
"""
import importlib.util
import sys
import pytest
def test_httpx_litellm_compatibility():
def _check_optional_dependency(package_name):
"""Centralized handling of optional dependency checks"""
if importlib.util.find_spec(package_name) is None:
pytest.skip(f"{package_name} not installed. Skipping compatibility test.")
return True
@pytest.fixture(autouse=True)
def log_versions():
"""Log all relevant package versions before tests"""
import httpx
import litellm
versions = {
"httpx": httpx.__version__,
}
print("\nRunning tests with versions:", versions)
return versions
class TestDependencyCompatibility:
"""Test suite for checking package dependency compatibility"""
def test_httpx_litellm_compatibility(self):
"""Test that litellm is compatible with the latest httpx"""
import httpx
import litellm
try:
assert hasattr(httpx, "__version__")
min_required_version = "0.28.1" # Minimum required version
from packaging import version
assert version.parse(httpx.__version__) >= version.parse(min_required_version)
except (AssertionError, ImportError) as e:
pytest.fail(f"httpx version {httpx.__version__} is not compatible. Minimum required: {min_required_version}. Error: {e}")
print(f"Using httpx version: {httpx.__version__}")
print("Successfully imported litellm")
def test_exa_py_compatibility():
def test_exa_py_compatibility(self):
"""Test that exa-py can be imported alongside litellm"""
if importlib.util.find_spec("exa") is None:
pytest.skip("exa-py not installed")
_check_optional_dependency("exa")
import exa
import httpx
@@ -31,11 +69,9 @@ def test_exa_py_compatibility():
print("Successfully imported litellm")
print(f"Using httpx version: {httpx.__version__}")
def test_google_genai_compatibility():
def test_google_genai_compatibility(self):
"""Test that google-genai can be imported alongside litellm"""
if importlib.util.find_spec("google.generativeai") is None:
pytest.skip("google-genai not installed")
_check_optional_dependency("google.generativeai")
import httpx
import litellm