MCPcopy Create free account
hub / github.com/bhowiebkr/PyFlowGraph / TestAnalyzer

Class TestAnalyzer

testing/test_analyzer.py:70–658  ·  view source on GitHub ↗

Advanced test analyzer with pattern recognition and recommendations.

Source from the content-addressed store, hash-verified

68 recommendations: List[str]
69
70class TestAnalyzer:
71 """Advanced test analyzer with pattern recognition and recommendations."""
72
73 def __init__(self, project_root: Path = None):
74 self.project_root = project_root or Path(__file__).parent
75 self.test_dir = self.project_root / "tests"
76 self.src_dir = self.project_root / "src"
77 self.db_path = self.project_root / "test_history.db"
78 self._init_database()
79
80 # Failure pattern definitions
81 self.failure_patterns = {
82 'import_error': {
83 'pattern': r'ModuleNotFoundError|ImportError',
84 'description': 'Module import failures',
85 'suggested_fix': 'Check PYTHONPATH and module dependencies'
86 },
87 'qt_application': {
88 'pattern': r'QApplication|QWidget.*RuntimeError',
89 'description': 'Qt application lifecycle issues',
90 'suggested_fix': 'Ensure proper QApplication setup/teardown in test fixtures'
91 },
92 'timeout': {
93 'pattern': r'timeout|TimeoutExpired',
94 'description': 'Test execution timeouts',
95 'suggested_fix': 'Optimize test performance or increase timeout limits'
96 },
97 'assertion': {
98 'pattern': r'AssertionError',
99 'description': 'Test assertion failures',
100 'suggested_fix': 'Review test expectations and actual behavior'
101 },
102 'attribute_error': {
103 'pattern': r'AttributeError',
104 'description': 'Missing attributes or methods',
105 'suggested_fix': 'Check object initialization and API changes'
106 },
107 'file_not_found': {
108 'pattern': r'FileNotFoundError|No such file',
109 'description': 'Missing test files or resources',
110 'suggested_fix': 'Verify test file paths and resource availability'
111 },
112 'memory_error': {
113 'pattern': r'MemoryError|OutOfMemoryError',
114 'description': 'Memory allocation failures',
115 'suggested_fix': 'Optimize memory usage or increase available memory'
116 }
117 }
118
119 def _init_database(self):
120 """Initialize SQLite database for test history tracking."""
121 conn = sqlite3.connect(self.db_path)
122 conn.execute('''
123 CREATE TABLE IF NOT EXISTS test_runs (
124 id INTEGER PRIMARY KEY AUTOINCREMENT,
125 timestamp TEXT NOT NULL,
126 test_name TEXT NOT NULL,
127 status TEXT NOT NULL,

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by 1

mainFunction · 0.68