auto flake and corrections
This commit is contained in:
+27
-21
@@ -5,7 +5,6 @@ Runs test and documentation coverage locally and generates badges.
|
||||
"""
|
||||
|
||||
import subprocess
|
||||
import sys
|
||||
import os
|
||||
|
||||
|
||||
@@ -15,7 +14,7 @@ def run_command(cmd, description):
|
||||
print(f"Running: {description}")
|
||||
print(f"Command: {cmd}")
|
||||
print(f"{'='*50}")
|
||||
|
||||
|
||||
try:
|
||||
result = subprocess.run(cmd, shell=True, check=True, capture_output=True, text=True)
|
||||
print(result.stdout)
|
||||
@@ -34,11 +33,11 @@ def main():
|
||||
"""Run full coverage analysis locally."""
|
||||
print("Local Coverage Analysis for pyWebLayout")
|
||||
print("=" * 60)
|
||||
|
||||
|
||||
# Change to project root if running from scripts directory
|
||||
if os.path.basename(os.getcwd()) == "scripts":
|
||||
os.chdir("..")
|
||||
|
||||
|
||||
# Install required packages
|
||||
print("\n1. Installing required packages...")
|
||||
packages = [
|
||||
@@ -46,28 +45,35 @@ def main():
|
||||
"coverage-badge",
|
||||
"interrogate"
|
||||
]
|
||||
|
||||
|
||||
for package in packages:
|
||||
if not run_command(f"pip install {package}", f"Installing {package}"):
|
||||
print(f"Failed to install {package}, continuing...")
|
||||
|
||||
|
||||
# Run tests with coverage
|
||||
print("\n2. Running tests with coverage...")
|
||||
test_cmd = "python -m pytest tests/ -v --cov=pyWebLayout --cov-report=term-missing --cov-report=json --cov-report=html --cov-report=xml"
|
||||
test_cmd = (
|
||||
"python -m pytest tests/ -v --cov=pyWebLayout "
|
||||
"--cov-report=term-missing --cov-report=json --cov-report=html --cov-report=xml"
|
||||
)
|
||||
run_command(test_cmd, "Running tests with coverage")
|
||||
|
||||
|
||||
# Generate test coverage badge
|
||||
print("\n3. Generating test coverage badge...")
|
||||
run_command("coverage-badge -o coverage.svg -f", "Generating test coverage badge")
|
||||
|
||||
|
||||
# Check documentation coverage
|
||||
print("\n4. Checking documentation coverage...")
|
||||
docs_cmd = "interrogate -v --ignore-init-method --ignore-init-module --ignore-magic --ignore-private --ignore-property-decorators --ignore-semiprivate --fail-under=80 --generate-badge coverage-docs.svg pyWebLayout/"
|
||||
docs_cmd = (
|
||||
"interrogate -v --ignore-init-method --ignore-init-module --ignore-magic "
|
||||
"--ignore-private --ignore-property-decorators --ignore-semiprivate "
|
||||
"--fail-under=80 --generate-badge coverage-docs.svg pyWebLayout/"
|
||||
)
|
||||
run_command(docs_cmd, "Checking documentation coverage")
|
||||
|
||||
|
||||
# Generate coverage summary
|
||||
print("\n5. Generating coverage summary...")
|
||||
|
||||
|
||||
# Write a temporary script to avoid shell quoting issues
|
||||
summary_script_content = '''import json
|
||||
import os
|
||||
@@ -75,30 +81,30 @@ import os
|
||||
if os.path.exists("coverage.json"):
|
||||
with open("coverage.json", "r") as f:
|
||||
coverage_data = json.load(f)
|
||||
|
||||
|
||||
total_coverage = round(coverage_data["totals"]["percent_covered"], 1)
|
||||
covered_lines = coverage_data["totals"]["covered_lines"]
|
||||
total_lines = coverage_data["totals"]["num_statements"]
|
||||
|
||||
|
||||
with open("coverage-summary.txt", "w") as f:
|
||||
f.write(f"{total_coverage}%")
|
||||
|
||||
|
||||
print(f"Test Coverage: {total_coverage}%")
|
||||
print(f"Lines Covered: {covered_lines}/{total_lines}")
|
||||
else:
|
||||
print("No coverage data found")
|
||||
'''
|
||||
|
||||
|
||||
# Write and execute temporary script
|
||||
with open('temp_coverage_summary.py', 'w') as f:
|
||||
f.write(summary_script_content)
|
||||
|
||||
success = run_command("python temp_coverage_summary.py", "Generating coverage summary")
|
||||
|
||||
|
||||
run_command("python temp_coverage_summary.py", "Generating coverage summary")
|
||||
|
||||
# Clean up temporary script
|
||||
if os.path.exists('temp_coverage_summary.py'):
|
||||
os.remove('temp_coverage_summary.py')
|
||||
|
||||
|
||||
# List generated files
|
||||
print("\n6. Generated files:")
|
||||
files = ["coverage.svg", "coverage-docs.svg", "coverage-summary.txt", "htmlcov/", "coverage.json", "coverage.xml"]
|
||||
@@ -107,7 +113,7 @@ else:
|
||||
print(f" ✓ {file}")
|
||||
else:
|
||||
print(f" ✗ {file} (not found)")
|
||||
|
||||
|
||||
print("\n" + "="*60)
|
||||
print("Coverage analysis complete!")
|
||||
print("To update your README with badges, run:")
|
||||
|
||||
Reference in New Issue
Block a user