1
Fork 0

Layout test file

This commit is contained in:
Jake Howard 2016-01-10 16:23:34 +00:00
parent b07890c3b0
commit 881bc20749

View file

@ -9,31 +9,35 @@ os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project.settings")
from django.core.management import execute_from_command_line from django.core.management import execute_from_command_line
init(autoreset=True) init(autoreset=True)
bin_dir = os.path.abspath(os.path.join(sys.executable, os.path.pardir))
bin_dir = os.path.abspath(os.path.join(sys.executable, os.path.pardir))
PERCENTAGE = 95 PERCENTAGE = 95
cov = coverage.Coverage( cov = coverage.Coverage(
source=["project"], source=["project"],
omit=["*/wsgi.py", "*/settings.py", "*/migrations/*.py", "*/__init__*"] omit=["*/wsgi.py", "*/settings.py", "*/migrations/*.py", "*/__init__*"]
) )
cov.start() cov.start()
print(Fore.YELLOW + "Running Tests...") print(Fore.YELLOW + "Running Tests...")
execute_from_command_line([sys.argv[0], 'test']) execute_from_command_line([sys.argv[0], 'test'])
cov.stop() cov.stop()
print(Fore.YELLOW + "Collecting Coverage...") print(Fore.YELLOW + "Collecting Coverage...")
cov.save() cov.save()
cov.html_report() cov.html_report()
covered = cov.report() covered = cov.report()
if covered <= PERCENTAGE: if covered <= PERCENTAGE:
print(Fore.RED + "ERROR: Your coverage needs to be higher. Current coverage: {}%. Required: {}%.".format(covered, PERCENTAGE)) print(Fore.RED + "ERROR: Your coverage needs to be higher. Current coverage: {}%. Required: {}%.".format(covered, PERCENTAGE))
exit(1) exit(1)
print(Fore.GREEN + "Coverage Complete.") print(Fore.GREEN + "Coverage Complete.")
FLAKE8_IGNORE = '--ignore=E128,E501,E401' FLAKE8_IGNORE = '--ignore=E128,E501,E401'
try: try:
subprocess.check_output([os.path.join(bin_dir, 'flake8'), 'project', FLAKE8_IGNORE, '--exclude=migrations,settings,wsgi.py']) subprocess.check_output([os.path.join(bin_dir, 'flake8'), 'project', FLAKE8_IGNORE, '--exclude=migrations,settings,wsgi.py'])
@ -46,6 +50,6 @@ except subprocess.CalledProcessError as e:
print(Fore.GREEN + "All Python tests passed!") print(Fore.GREEN + "All Python tests passed!")
os.system('npm test')
os.system('npm test')
print(Fore.GREEN + "All Tests Passed!") print(Fore.GREEN + "All Tests Passed!")