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

Function main

testing/test_generator.py:725–808  ·  view source on GitHub ↗

Main entry point for the test generator.

()

Source from the content-addressed store, hash-verified

723 }
724
725def main():
726 """Main entry point for the test generator."""
727 parser = argparse.ArgumentParser(
728 description="Test Generator for PyFlowGraph",
729 formatter_class=argparse.RawDescriptionHelpFormatter,
730 epilog="""
731Examples:
732 python test_generator.py # Generate tests for top 10 complex functions
733 python test_generator.py --max-functions 5 # Generate tests for top 5 functions
734 python test_generator.py --min-complexity 2.0 # Only functions with complexity >= 2.0
735 python test_generator.py --output-dir custom/ # Custom output directory
736 """
737 )
738
739 parser.add_argument("--max-functions", type=int, default=10,
740 help="Maximum number of functions to generate tests for")
741 parser.add_argument("--min-complexity", type=float, default=1.0,
742 help="Minimum complexity score for test generation")
743 parser.add_argument("--output-dir", type=Path,
744 help="Output directory for generated tests")
745 parser.add_argument("--analyze-only", action="store_true",
746 help="Only analyze coverage gaps, don't generate tests")
747 parser.add_argument("--format", choices=["detailed", "summary", "claude"],
748 default="detailed", help="Output format")
749
750 args = parser.parse_args()
751
752 try:
753 generator = TestGenerator()
754
755 if args.analyze_only:
756 # Just analyze gaps
757 functions = generator.analyze_coverage_gaps()
758 if args.format == "claude":
759 print(f"Coverage Gaps: {len(functions)} functions need tests")
760 for func in functions[:5]:
761 print(f"• {func.file_path}::{func.name} (complexity: {func.complexity_score:.1f})")
762 elif args.format == "summary":
763 print(f"Found {len(functions)} functions needing tests")
764 else:
765 print(f"Coverage Analysis Results:")
766 print(f"Total functions needing tests: {len(functions)}")
767 for func in functions:
768 print(f" {func.file_path}::{func.name}")
769 print(f" Complexity: {func.complexity_score:.1f}")
770 print(f" Line: {func.line_number}")
771 if func.docstring:
772 print(f" Doc: {func.docstring[:60]}...")
773 print()
774 else:
775 # Analyze and generate
776 result = generator.analyze_and_generate(
777 max_functions=args.max_functions,
778 min_complexity=args.min_complexity,
779 output_dir=args.output_dir
780 )
781
782 if args.format == "claude":

Callers 1

test_generator.pyFile · 0.70

Calls 3

analyze_coverage_gapsMethod · 0.95
analyze_and_generateMethod · 0.95
TestGeneratorClass · 0.85

Tested by

no test coverage detected