/
Watashicuvu
/
agentic-tools
Обзор
Документация
Войти
/
Watashicuvu
/
agentic-tools
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
src/tests/test_normalization.py
90 строк
3 KB
Якуб
minor changes
27 фев 2026, 21:11
27 фев 2026, 21:11
07e8675
Код
Авторство
О чём код?
#!/usr/bin/env python3 """Test error message normalization.""" import sys from pathlib import Path sys.path.insert(0, str(Path.cwd())) from src.services.runtime_analyzer import normalize_error_message def test_normalization(): """Tests for normalize_error_message function.""" test_cases = [ # (input, expected_pattern) ( "File '/home/user/projects/data.json' not found", "File PATH not found" ), ( "File 'C:\\Users\\user\\data.json' not found", "File PATH not found" ), ( "ValidationError: user_id must be a positive integer, got -5", "ValidationError: user_id must be a positive integer" ), ( "Connection timeout after 30.5 seconds to host 192.168.1.1", "Connection timeout after N seconds to host IP" ), ( "Invalid UUID: 550e8400-e29b-41d4-a716-446655440000", "Invalid UUID: UUID" ), ( "Hash mismatch: expected d41d8cd98f00b204e9800998ecf8427e", "Hash mismatch: expected HASH" ), ( "KeyError: 'user_12345' - User not found in database", "KeyError: 'user_N' - User not found in database" ), ( "Division by zero in calculation at line 42", "Division by zero in calculation at line 42" # Номер строки сохраняется ), ( "ValueError: invalid literal for int() with base 10: 'abc123xyz'", "ValueError: invalid literal for int() with base 10: 'abc123xyz'" ), ( "Connection to 10.0.0.1:8080 failed after 3 retries", "Connection to IP:8080 failed after N retries" ), ] logging.debug("🧪 Testing normalize_error_message()\n") passed = 0 failed = 0 for i, (input_msg, expected_pattern) in enumerate(test_cases, 1): result = normalize_error_message(input_msg) # Простая проверка: некоторые ключевые слова должны совпадать if expected_pattern in result or result == expected_pattern: logging.debug(f"✅ Test {i}: PASS") logging.debug(f" Input: {input_msg}") logging.debug(f" Output: {result}") passed += 1 else: logging.debug(f"⚠️ Test {i}: PARTIAL (check manually)") logging.debug(f" Input: {input_msg}") logging.debug(f" Expected: {expected_pattern}") logging.debug(f" Got: {result}") failed += 1 logging.debug() logging.debug(f"{'='*60}") logging.debug(f"📊 Results: {passed} passed, {failed} needs review") logging.debug(f"{'='*60}") return failed == 0 if __name__ == "__main__": success = test_normalization() sys.exit(0 if success else 1)