Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /ViperJuice_Code-Index-MCP /tests /root_tests /test_logging.py
| #!/usr/bin/env python3 | |
| """Test the logging and error handling infrastructure.""" | |
| import os | |
| import sys | |
| # Add the project root to the Python path | |
| sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) | |
| from mcp_server.core import ConfigError, IndexError, MCPError, PluginError, get_logger | |
| def test_logging(): | |
| """Test logging functionality.""" | |
| logger = get_logger(__name__) | |
| print("Testing logging levels...") | |
| logger.debug("This is a DEBUG message") | |
| logger.info("This is an INFO message") | |
| logger.warning("This is a WARNING message") | |
| logger.error("This is an ERROR message") | |
| print("\nTesting logger from different module...") | |
| test_logger = get_logger("test.module") | |
| test_logger.info("Testing logger with custom name") | |
| def test_errors(): | |
| """Test custom error classes.""" | |
| print("\n\nTesting error classes...") | |
| # Test MCPError | |
| try: | |
| raise MCPError("Basic MCP error") | |
| except MCPError as e: | |
| print(f"MCPError: {e}") | |
| # Test MCPError with details | |
| try: | |
| raise MCPError("MCP error with details", {"code": 500, "reason": "test"}) | |
| except MCPError as e: | |
| print(f"MCPError with details: {e}") | |
| # Test PluginError | |
| try: | |
| raise PluginError("python_plugin", "Failed to parse file") | |
| except PluginError as e: | |
| print(f"PluginError: {e}") | |
| # Test IndexError | |
| try: | |
| raise IndexError("Invalid syntax", "/path/to/file.py") | |
| except IndexError as e: | |
| print(f"IndexError: {e}") | |
| # Test ConfigError | |
| try: | |
| raise ConfigError("Invalid value", "log_level") | |
| except ConfigError as e: | |
| print(f"ConfigError: {e}") | |
| if __name__ == "__main__": | |
| test_logging() | |
| test_errors() | |
| print("\n\nCheck mcp_server.log for log output.") | |
Xet Storage Details
- Size:
- 1.79 kB
- Xet hash:
- a86f4be975477f47ce941057be09c302d757906a2082a23ebc3982fdac2bef2c
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.