-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathauto_run.py
More file actions
34 lines (26 loc) · 901 Bytes
/
auto_run.py
File metadata and controls
34 lines (26 loc) · 901 Bytes
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
from app import create_app, db
from app.models import User
from app.forms import UserForm
from flask_migrate import Migrate
import os
import unittest
app = create_app(os.environ.get('CONFIG') or 'config.DevelopmentConfig')
migrate = Migrate(app, db)
@app.shell_context_processor
def make_shell_context():
"""Creates shell context for our shell session when using Flask shell
Gives us access to our app, database and User Model in terminal.
http://flask.pocoo.org/docs/0.12/cli/#cli
"""
return dict(app=app, db=db, User=User, UserForm=UserForm)
@app.cli.command()
def test():
"""Runs the unit tests without test coverage."""
tests = unittest.TestLoader().discover('tests', pattern='test*.py')
result = unittest.TextTestRunner(verbosity=2).run(tests)
if result.wasSuccessful():
return 0
return 1
@app.cli.command()
def hello():
print('hello')