-
Notifications
You must be signed in to change notification settings - Fork 1
/
manage.py
executable file
·41 lines (33 loc) · 1.01 KB
/
manage.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import sys
import unittest
import coverage
from project import create_app
if len(sys.argv) < 1:
raise AttributeError('Please provide an option')
if sys.argv[1] not in ['runserver', 'test', 'coverage']:
raise AttributeError('Option not supported')
if sys.argv[1] == 'runserver':
app = create_app('config.Development')
app.run()
if sys.argv[1] == 'test':
tests = unittest.TestLoader().discover('tests', pattern='*.py')
unittest.TextTestRunner(verbosity=1).run(tests)
if sys.argv[1] == 'coverage':
cov = coverage.coverage(
branch=True,
include='project/*'
)
cov.start()
tests = unittest.TestLoader().discover('tests', pattern='*.py')
unittest.TextTestRunner(verbosity=2).run(tests)
cov.stop()
cov.save()
print('Coverage Summary:')
cov.report()
basedir = os.path.abspath(os.path.dirname(__file__))
covdir = os.path.join(basedir, 'coverage')
cov.html_report(directory=covdir)
cov.erase()