Skip to content

Commit fe3c12e

Browse files
author
Martin Møldrup
committed
Make the mcp test only run if mcp is installed
1 parent 65ace86 commit fe3c12e

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

.github/workflows/continuous_integration.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
strategy:
4040
fail-fast: false
4141
matrix:
42-
python-version: [3.9, 3.13]
42+
python-version: [3.10, 3.13]
4343
include-extras: [true]
4444
include:
4545
- python-version: 3.9

tests/mcp_server_test.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,26 @@
1+
"""Test for mcp server tool availability."""
2+
13
import pytest
4+
import importlib.util
25
import toolit.create_apps_and_register as create_apps_and_register
36

7+
mcp_spec = importlib.util.find_spec("mcp")
8+
mcp_installed: bool = mcp_spec is not None
9+
410

11+
@pytest.mark.skipif(not mcp_installed, reason="mcp package is not installed")
512
@pytest.mark.asyncio
613
async def test_mcp_server() -> None:
714
"""Test the mcp server tool is available."""
15+
assert create_apps_and_register.mcp is not None, (
16+
"This test should only run if mcp is installed. create_apps_and_register.mcp is None indicating it is not installed."
17+
)
818

919
def some_tool() -> None:
1020
"""Tool for testing purpose."""
1121
pass
1222

1323
create_apps_and_register.register_command(some_tool, name="some_tool")
1424
tools = await create_apps_and_register.mcp.list_tools()
15-
tool_instance = [tool for tool in tools if tool.name == "some_tool"][0]
25+
tool_instance = next(tool for tool in tools if tool.name == "some_tool")
1626
assert bool(tool_instance) is not False

0 commit comments

Comments
 (0)