Files
crewAI/lib/tools/tests/test_optional_dependencies.py
Greyson LaLonde e2270456c4 feat: add crewai-tools library to workspace
- Migrate crewai-tools as standalone package in lib/tools
- Configure UV workspace for monorepo structure
- Move assets to repository root
- Clean up duplicate README files
- Focus pre-commit hooks on lib/crewai/src only
2025-09-26 15:05:41 -04:00

41 lines
1.2 KiB
Python

import subprocess
import tempfile
from pathlib import Path
import pytest
@pytest.fixture
def temp_project():
temp_dir = tempfile.TemporaryDirectory()
project_dir = Path(temp_dir.name) / "test_project"
project_dir.mkdir()
pyproject_content = f"""
[project]
name = "test-project"
version = "0.1.0"
description = "Test project"
requires-python = ">=3.10"
"""
(project_dir / "pyproject.toml").write_text(pyproject_content)
run_command(["uv", "add", "--editable", f"file://{Path.cwd().absolute()}"], project_dir)
run_command(["uv", "sync"], project_dir)
yield project_dir
def run_command(cmd, cwd):
return subprocess.run(cmd, cwd=cwd, capture_output=True, text=True)
def test_no_optional_dependencies_in_init(temp_project):
"""
Test that crewai-tools can be imported without optional dependencies.
The package defines optional dependencies in pyproject.toml, but the base
package should be importable without any of these optional dependencies
being installed.
"""
result = run_command(["uv", "run", "python", "-c", "import crewai_tools"], temp_project)
assert result.returncode == 0, f"Import failed with error: {result.stderr}"