Skip to content

Commit c987331

Browse files
committed
test: Skip MCP tests when Python version is less than 3.10
- Add Python version check to test_mcp_toolset.py - Follow existing MCP test pattern with pytestmark skipif decorator - Add import error handling with dummy classes for test collection - Addresses review comment from seanzhou1023
1 parent dd42312 commit c987331

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

tests/unittests/tools/test_mcp_toolset.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,31 @@
1414

1515
"""Unit tests for McpToolset."""
1616

17+
import sys
1718
from unittest.mock import AsyncMock
1819
from unittest.mock import MagicMock
1920

20-
from google.adk.tools.mcp_tool.mcp_toolset import McpToolset
2121
import pytest
2222

23+
# Skip all tests in this module if Python version is less than 3.10
24+
pytestmark = pytest.mark.skipif(
25+
sys.version_info < (3, 10), reason="MCP tool requires Python 3.10+"
26+
)
27+
28+
# Import dependencies with version checking
29+
try:
30+
from google.adk.tools.mcp_tool.mcp_toolset import McpToolset
31+
except ImportError as e:
32+
if sys.version_info < (3, 10):
33+
# Create dummy classes to prevent NameError during test collection
34+
# Tests will be skipped anyway due to pytestmark
35+
class DummyClass:
36+
pass
37+
38+
McpToolset = DummyClass
39+
else:
40+
raise e
41+
2342

2443
@pytest.mark.asyncio
2544
async def test_mcp_toolset_with_prefix():

0 commit comments

Comments
 (0)