1
Fork 0
This repository has been archived on 2023-03-26. You can view files and clone it, but cannot push or open issues or pull requests.
theorangeone.net-legacy/scripts/check-coverage.py

27 lines
685 B
Python
Executable file

#!/usr/bin/env python3
import coverage
import subprocess
RED = "\033[31m"
GREEN = "\033[32m"
YELLOW = "\033[33m"
NORMAL = "\033[0m"
PERCENTAGE = 95
cov = coverage.Coverage(
source=["project"],
omit=["*/wsgi.py", "*/settings.py", "*/migrations/*.py", "*/__init__*"]
)
cov.start()
print(YELLOW + "Running Tests..." + NORMAL)
subprocess.check_output(["manage.py", "test"])
cov.stop()
print(YELLOW + "Collecting Coverage..." + NORMAL)
covered = cov.report()
if covered <= PERCENTAGE:
print(RED + "ERROR: Your coverage needs to be higher. Current coverage: {}%. Required: {}%.".format(covered, PERCENTAGE) + NORMAL)
exit(1)
print(GREEN + "Coverage Complete." + NORMAL)