mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-11 00:58:30 +00:00
fix: Implement reviewer suggestions for test improvements and version constraints
Co-Authored-By: Joe Moura <joao@crewai.com>
This commit is contained in:
@@ -11,7 +11,7 @@ dependencies = [
|
|||||||
# Core Dependencies
|
# Core Dependencies
|
||||||
"pydantic>=2.4.2",
|
"pydantic>=2.4.2",
|
||||||
"openai>=1.13.3",
|
"openai>=1.13.3",
|
||||||
"litellm>=1.65.1",
|
"litellm>=1.65.1,<2.0.0",
|
||||||
"instructor>=1.3.3",
|
"instructor>=1.3.3",
|
||||||
# Text Processing
|
# Text Processing
|
||||||
"pdfplumber>=0.11.4",
|
"pdfplumber>=0.11.4",
|
||||||
|
|||||||
@@ -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 importlib.util
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import pytest
|
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"""
|
"""Test that litellm is compatible with the latest httpx"""
|
||||||
import httpx
|
import httpx
|
||||||
import litellm
|
import litellm
|
||||||
|
|
||||||
|
try:
|
||||||
assert hasattr(httpx, "__version__")
|
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(f"Using httpx version: {httpx.__version__}")
|
||||||
print("Successfully imported litellm")
|
print("Successfully imported litellm")
|
||||||
|
|
||||||
|
def test_exa_py_compatibility(self):
|
||||||
def test_exa_py_compatibility():
|
|
||||||
"""Test that exa-py can be imported alongside litellm"""
|
"""Test that exa-py can be imported alongside litellm"""
|
||||||
if importlib.util.find_spec("exa") is None:
|
_check_optional_dependency("exa")
|
||||||
pytest.skip("exa-py not installed")
|
|
||||||
|
|
||||||
import exa
|
import exa
|
||||||
import httpx
|
import httpx
|
||||||
@@ -31,11 +69,9 @@ def test_exa_py_compatibility():
|
|||||||
print("Successfully imported litellm")
|
print("Successfully imported litellm")
|
||||||
print(f"Using httpx version: {httpx.__version__}")
|
print(f"Using httpx version: {httpx.__version__}")
|
||||||
|
|
||||||
|
def test_google_genai_compatibility(self):
|
||||||
def test_google_genai_compatibility():
|
|
||||||
"""Test that google-genai can be imported alongside litellm"""
|
"""Test that google-genai can be imported alongside litellm"""
|
||||||
if importlib.util.find_spec("google.generativeai") is None:
|
_check_optional_dependency("google.generativeai")
|
||||||
pytest.skip("google-genai not installed")
|
|
||||||
|
|
||||||
import httpx
|
import httpx
|
||||||
import litellm
|
import litellm
|
||||||
|
|||||||
Reference in New Issue
Block a user