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

Method generate_recommendations

testing/test_analyzer.py:457–498  ·  view source on GitHub ↗

Generate actionable recommendations based on analysis.

(self, analysis_report: TestAnalysisReport)

Source from the content-addressed store, hash-verified

455 return max(score, 0.0)
456
457 def generate_recommendations(self, analysis_report: TestAnalysisReport) -> List[str]:
458 """Generate actionable recommendations based on analysis."""
459 recommendations = []
460
461 # Failure pattern recommendations
462 if analysis_report.failure_patterns:
463 top_pattern = analysis_report.failure_patterns[0]
464 recommendations.append(
465 f"Priority: Fix {top_pattern.category} failures affecting {top_pattern.frequency} tests. "
466 f"Suggestion: {top_pattern.suggested_fix}"
467 )
468
469 # Coverage recommendations
470 high_priority_gaps = [gap for gap in analysis_report.coverage_gaps if gap.priority == 'HIGH']
471 if high_priority_gaps:
472 recommendations.append(
473 f"Add tests for {len(high_priority_gaps)} high-priority uncovered functions. "
474 f"Start with: {high_priority_gaps[0].file_path}::{high_priority_gaps[0].function_name}"
475 )
476
477 # Performance recommendations
478 if analysis_report.performance_issues:
479 slowest = analysis_report.performance_issues[0]
480 recommendations.append(
481 f"Optimize slow test: {slowest.test_name} ({slowest.duration:.2f}s). "
482 f"Suggestion: {slowest.optimization_suggestion}"
483 )
484
485 # Flaky test recommendations
486 if analysis_report.flaky_tests:
487 recommendations.append(
488 f"Investigate {len(analysis_report.flaky_tests)} flaky tests for non-deterministic behavior. "
489 f"Start with: {analysis_report.flaky_tests[0]}"
490 )
491
492 # Health score recommendations
493 if analysis_report.test_health_score < 70:
494 recommendations.append(
495 "Test suite health is below 70%. Focus on reducing failures and improving coverage."
496 )
497
498 return recommendations
499
500 def analyze(self, results_file: Path = None) -> TestAnalysisReport:
501 """Perform comprehensive test analysis."""

Callers 1

analyzeMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected