#!/usr/bin/env python """ Simple script to generate a test report. This is a simplified version of run_tests.py focused on generating the JSON report. """ import os import subprocess import sys from datetime import datetime def main(): """Run tests and generate JSON report.""" # Create directories if they don't exist os.makedirs("test_reports", exist_ok=True) # Generate timestamp for current run timestamp = datetime.now().strftime("%Y%m%d_%H%M%S") print(f"Running tests and generating JSON report with timestamp: {timestamp}") # Run pytest with the JSON reporter plugin loaded cmd = [ "pytest", "-v", "--tb=short", f"--junitxml=test_reports/junit_{timestamp}.xml", "-p", "tests.json_reporter", "tests/", ] result = subprocess.run(cmd, capture_output=False) if result.returncode == 0: print("\nTests completed successfully!") else: print(f"\nTests completed with some failures (exit code: {result.returncode})") print( f"JSON report should be available at: test_reports/test_results_{timestamp}.json" ) return result.returncode if __name__ == "__main__": sys.exit(main())