-
Notifications
You must be signed in to change notification settings - Fork 0
/
manage.py
49 lines (34 loc) · 1.16 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
42
43
44
45
46
47
48
49
import os
import coverage
from flask_migrate import Migrate, MigrateCommand
from flask_script import Manager, Shell
from app import create_app, db
from app.models import Dictionary, User, Word
from config import basedir
app = create_app(os.getenv('MYDICTIONARY_CONFIG') or 'default')
migrate = Migrate(app, db)
manager = Manager(app)
def make_shell_context():
return dict(app=app, db=db, User=User, Dictionary=Dictionary, Word=Word)
manager.add_command('shell', Shell(make_context=make_shell_context))
manager.add_command('db', MigrateCommand)
cov = coverage.coverage(branch=True, include='app/*')
@manager.command
def test(coverage=False):
""" Run the unit tests. """
if coverage:
cov.start()
import unittest
tests = unittest.TestLoader().discover('tests')
unittest.TextTestRunner(verbosity=2).run(tests)
if coverage:
cov.stop()
cov.save()
print('Coverage Summary:')
cov.report()
cov_dir = os.path.join(basedir, 'tmp/coverage')
cov.html_report(directory=cov_dir)
print('HTML version: %s/index.html' % cov_dir)
cov.erase()
if __name__ == '__main__':
manager.run()