forked from miguelgrinberg/flasky
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flasky.py
25 lines (20 loc) · 700 Bytes
/
flasky.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
import os
import click
from flask_migrate import Migrate
from app import create_app, db
from app.models import User, Role, Permission, Post
app = create_app(os.getenv('FLASK_CONFIG') or 'default')
migrate = Migrate(app, db)
@app.shell_context_processor
def make_shell_context():
return dict(db=db, User=User, Role=Role, Permission=Permission, Post=Post)
@app.cli.command()
@click.argument('test_names', nargs=-1)
def test(test_names):
"""Run the unit tests."""
import unittest
if test_names:
tests = unittest.TestLoader().loadTestsFromNames(test_names)
else:
tests = unittest.TestLoader().discover('tests')
unittest.TextTestRunner(verbosity=2).run(tests)