app = creat_app('development')
app.app_context().push()
app.config['debug'] = True
manager = Manager(app)
COV = None
if os.environ.get('FLASK_COVERAGE'):
import coverage
COV = coverage.coverage(branch=True, include='app/*')
COV.start()
@
manager.command
def test(cover=False):
"""run the unittest"""
if cover and not os.environ.get('FLASK_COVERAGE'):
import sys
os.environ['FLASK_COVERAGE'] = '1'
os.execvp(sys.executable, [sys.executable] + sys.argv)
import unittest
tests = unittest.TestLoader().discover('test')
unittest.TextTestRunner(verbosity=2).run(tests)
if COV:
COV.stop()
COV.save()
print 'Coverage Summary:'
COV.report()
basedir = os.path.abspath(os.path.dirname(__file__))
covdir = os.path.join(basedir, 'tmp/coverage')
COV.html_report(directory=covdir)
print 'html version: file://%s/index.html' % covdir
COV.erase()
if __name__ == '__main__':
print app.url_map
db.drop_all()
db.create_all()
manager.run()