-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanalyze_test_failures.py
More file actions
93 lines (74 loc) · 2.63 KB
/
analyze_test_failures.py
File metadata and controls
93 lines (74 loc) · 2.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/usr/bin/env python3
"""
Quick script to identify common patterns in failing tests that need v3 updates.
"""
import subprocess
import sys
def run_tests_and_get_failures():
"""Run tests and extract failure information."""
result = subprocess.run(
["python", "-m", "pytest", "--tb=no", "-q"],
capture_output=True,
text=True,
timeout=120
)
output = result.stdout + result.stderr
# Extract FAILED lines
failures = []
for line in output.split('\n'):
if line.strip().startswith('FAILED'):
failures.append(line.strip())
return failures
def categorize_failures(failures):
"""Categorize failures by type."""
categories = {
'v3_sheets': [],
'v3_columns': [],
'v3_as_field': [],
'matcher_count': [],
'model_validation': [],
'other': []
}
for failure in failures:
if "'MappingConfig' object has no attribute 'sheets'" in failure:
categories['v3_sheets'].append(failure)
elif "'SheetMapping' object has no attribute 'columns'" in failure or "'.columns'" in failure:
categories['v3_columns'].append(failure)
elif "'as' in" in failure or "['as']" in failure:
categories['v3_as_field'].append(failure)
elif "Expected 17 matchers" in failure or "matchers to fire" in failure:
categories['matcher_count'].append(failure)
elif "ValidationError" in failure or "pydantic" in failure:
categories['model_validation'].append(failure)
else:
categories['other'].append(failure)
return categories
def main():
print("🔍 Analyzing test failures...")
print("=" * 70)
try:
failures = run_tests_and_get_failures()
if not failures:
print("✅ No failures found!")
return 0
print(f"\n📊 Total Failures: {len(failures)}\n")
categories = categorize_failures(failures)
for category, items in categories.items():
if items:
print(f"\n{category.upper().replace('_', ' ')} ({len(items)} failures):")
print("-" * 70)
for item in items[:5]: # Show first 5
print(f" • {item[:100]}...")
if len(items) > 5:
print(f" ... and {len(items) - 5} more")
print("\n" + "=" * 70)
print(f"✅ Analysis complete!")
except subprocess.TimeoutExpired:
print("⏰ Tests timed out")
return 1
except Exception as e:
print(f"❌ Error: {e}")
return 1
return 0
if __name__ == "__main__":
sys.exit(main())