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

29 lines
659 B
Python
Raw Normal View History

2016-01-09 22:56:48 +00:00
#!/usr/bin/env python3
import coverage
2016-01-10 12:01:39 +00:00
import os
2016-01-09 22:56:48 +00:00
RED = "\033[31m"
GREEN = "\033[32m"
YELLOW = "\033[33m"
NORMAL = "\033[0m"
2016-01-10 12:01:39 +00:00
2016-01-09 22:56:48 +00:00
PERCENTAGE = 95
cov = coverage.Coverage(
source=["project"],
omit=["*/wsgi.py", "*/settings.py", "*/migrations/*.py", "*/__init__*"]
)
cov.start()
print(YELLOW + "Running Tests..." + NORMAL)
2016-01-10 12:01:39 +00:00
os.system('manage.py test')
2016-01-09 22:56:48 +00:00
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)