Skip to content

Run tests with extra dependencies separately #8246

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ jobs:
args: check --fix-only
- name: Run tests with pytest
run: uv run -p .venv pytest tests/
- name: Install optional dependencies
run: uv sync -p .venv --extra dev --extra test_extras
- name: Run extra tests
run: uv run -p .venv pytest tests/ -m extra --extra

build_package:
name: Build Package
Expand Down
6 changes: 4 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ dependencies = [
anthropic = ["anthropic>=0.18.0,<1.0.0"]
weaviate = ["weaviate-client~=4.5.4"]
aws = ["boto3~=1.34.78"]
mcp = ["mcp; python_version >= '3.10'"]
dev = [
"pytest>=6.2.5",
"pytest-mock>=3.12.0",
Expand All @@ -62,9 +63,10 @@ dev = [
"build>=1.0.3",
"litellm>=1.60.3; sys_platform == 'win32'",
"litellm[proxy]>=1.60.3; sys_platform != 'win32'",
"mcp>=1.5.0; python_version >= '3.10'",
]
mcp = ["mcp; python_version >= '3.10'"]
test_extras = [
"mcp; python_version >= '3.10'",
]

[tool.setuptools.packages.find]
where = ["."]
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from tests.test_utils.server import litellm_test_server, read_litellm_test_server_request_logs # noqa: F401

SKIP_DEFAULT_FLAGS = ["reliability"]
SKIP_DEFAULT_FLAGS = ["reliability", "extra"]


@pytest.fixture(autouse=True)
Expand Down
9 changes: 7 additions & 2 deletions tests/utils/test_mcp.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
import asyncio
import importlib

import pytest
from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client

from dspy.utils.mcp import convert_mcp_tool

if importlib.util.find_spec("mcp") is None:
pytest.skip(reason="mcp is not installed", allow_module_level=True)


@pytest.mark.asyncio
@pytest.mark.extra
async def test_convert_mcp_tool():
from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client
server_params = StdioServerParameters(
command="python",
args=["tests/utils/resources/mcp_server.py"],
Expand Down
10 changes: 6 additions & 4 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.