Detailed human-readable format.
(self, report: TestAnalysisReport)
| 596 | ) |
| 597 | |
| 598 | def _format_detailed_report(self, report: TestAnalysisReport) -> str: |
| 599 | """Detailed human-readable format.""" |
| 600 | lines = [ |
| 601 | "=" * 60, |
| 602 | "PyFlowGraph Test Analysis Report", |
| 603 | "=" * 60, |
| 604 | f"Generated: {report.timestamp}", |
| 605 | f"Test Health Score: {report.test_health_score:.1f}/100", |
| 606 | "" |
| 607 | ] |
| 608 | |
| 609 | # Failure patterns |
| 610 | if report.failure_patterns: |
| 611 | lines.append("Failure Patterns:") |
| 612 | for pattern in report.failure_patterns: |
| 613 | lines.append(f" {pattern.category}: {pattern.frequency} occurrences") |
| 614 | lines.append(f" Pattern: {pattern.pattern}") |
| 615 | lines.append(f" Description: {pattern.description}") |
| 616 | lines.append(f" Suggested Fix: {pattern.suggested_fix}") |
| 617 | if pattern.affected_tests: |
| 618 | lines.append(f" Affected Tests: {', '.join(pattern.affected_tests[:3])}") |
| 619 | if len(pattern.affected_tests) > 3: |
| 620 | lines.append(f" ... and {len(pattern.affected_tests) - 3} more") |
| 621 | lines.append("") |
| 622 | |
| 623 | # Coverage gaps |
| 624 | if report.coverage_gaps: |
| 625 | lines.append("Coverage Gaps:") |
| 626 | high_gaps = [gap for gap in report.coverage_gaps if gap.priority == 'HIGH'] |
| 627 | if high_gaps: |
| 628 | lines.append(" High Priority:") |
| 629 | for gap in high_gaps: |
| 630 | lines.append(f" {gap.file_path}::{gap.function_name}") |
| 631 | lines.append(f" Missing lines: {gap.line_numbers}") |
| 632 | lines.append(f" Complexity: {gap.complexity_score:.2f}") |
| 633 | lines.append("") |
| 634 | |
| 635 | # Performance issues |
| 636 | if report.performance_issues: |
| 637 | lines.append("Performance Issues:") |
| 638 | for issue in report.performance_issues: |
| 639 | lines.append(f" {issue.test_name}: {issue.duration:.2f}s") |
| 640 | lines.append(f" Category: {issue.category}") |
| 641 | lines.append(f" Bottleneck: {issue.bottleneck_type}") |
| 642 | lines.append(f" Suggestion: {issue.optimization_suggestion}") |
| 643 | lines.append("") |
| 644 | |
| 645 | # Flaky tests |
| 646 | if report.flaky_tests: |
| 647 | lines.append(f"Flaky Tests ({len(report.flaky_tests)}):") |
| 648 | for test in report.flaky_tests: |
| 649 | lines.append(f" {test}") |
| 650 | lines.append("") |
| 651 | |
| 652 | # Recommendations |
| 653 | if report.recommendations: |
| 654 | lines.append("Recommendations:") |
| 655 | for i, rec in enumerate(report.recommendations, 1): |