fix: Add TextContent fallback class for test compatibility
- Replace TextContent = None with proper fallback class in all MCP tool modules
- Fixes TypeError when MCP library is not fully initialized in test environment
- Ensures all 700 tests pass (was 699 passing, 1 failing)
- Affected files:
* packaging_tools.py
* config_tools.py
* scraping_tools.py
* source_tools.py
* splitting_tools.py
The fallback class maintains the same interface as mcp.types.TextContent,
allowing tests to run successfully even when the MCP library import fails.
Test results: ✅ 700 passed, 157 skipped, 2 warnings
This commit is contained in:
@@ -13,7 +13,12 @@ from typing import Any, List
|
||||
try:
|
||||
from mcp.types import TextContent
|
||||
except ImportError:
|
||||
TextContent = None
|
||||
# Graceful degradation: Create a simple fallback class for testing
|
||||
class TextContent:
|
||||
"""Fallback TextContent for when MCP is not installed"""
|
||||
def __init__(self, type: str, text: str):
|
||||
self.type = type
|
||||
self.text = text
|
||||
|
||||
# Path to CLI tools
|
||||
CLI_DIR = Path(__file__).parent.parent.parent / "cli"
|
||||
|
||||
@@ -18,7 +18,12 @@ from typing import Any, List, Tuple
|
||||
try:
|
||||
from mcp.types import TextContent
|
||||
except ImportError:
|
||||
TextContent = None # Graceful degradation
|
||||
# Graceful degradation: Create a simple fallback class for testing
|
||||
class TextContent:
|
||||
"""Fallback TextContent for when MCP is not installed"""
|
||||
def __init__(self, type: str, text: str):
|
||||
self.type = type
|
||||
self.text = text
|
||||
|
||||
|
||||
# Path to CLI tools
|
||||
|
||||
@@ -19,7 +19,12 @@ from typing import Any, List
|
||||
try:
|
||||
from mcp.types import TextContent
|
||||
except ImportError:
|
||||
TextContent = None # Graceful degradation for testing
|
||||
# Graceful degradation: Create a simple fallback class for testing
|
||||
class TextContent:
|
||||
"""Fallback TextContent for when MCP is not installed"""
|
||||
def __init__(self, type: str, text: str):
|
||||
self.type = type
|
||||
self.text = text
|
||||
|
||||
# Path to CLI tools
|
||||
CLI_DIR = Path(__file__).parent.parent.parent / "cli"
|
||||
|
||||
@@ -20,7 +20,12 @@ try:
|
||||
from mcp.types import TextContent
|
||||
MCP_AVAILABLE = True
|
||||
except ImportError:
|
||||
TextContent = None
|
||||
# Graceful degradation: Create a simple fallback class for testing
|
||||
class TextContent:
|
||||
"""Fallback TextContent for when MCP is not installed"""
|
||||
def __init__(self, type: str, text: str):
|
||||
self.type = type
|
||||
self.text = text
|
||||
MCP_AVAILABLE = False
|
||||
|
||||
import httpx
|
||||
|
||||
@@ -13,7 +13,12 @@ from typing import Any, List
|
||||
try:
|
||||
from mcp.types import TextContent
|
||||
except ImportError:
|
||||
TextContent = None
|
||||
# Graceful degradation: Create a simple fallback class for testing
|
||||
class TextContent:
|
||||
"""Fallback TextContent for when MCP is not installed"""
|
||||
def __init__(self, type: str, text: str):
|
||||
self.type = type
|
||||
self.text = text
|
||||
|
||||
# Path to CLI tools
|
||||
CLI_DIR = Path(__file__).parent.parent.parent / "cli"
|
||||
|
||||
Reference in New Issue
Block a user