Skip to content

Instantly share code, notes, and snippets.

@wiesson
Last active August 29, 2015 14:02
Show Gist options
  • Save wiesson/b4a97ba79541638809c9 to your computer and use it in GitHub Desktop.
Save wiesson/b4a97ba79541638809c9 to your computer and use it in GitHub Desktop.
# !/usr/bin/env python
import os
import argparse
from app import create_app
from flask.ext.script import Manager
parser = argparse.ArgumentParser()
parser.add_argument("go", help="runserver, test, shell")
args = parser.parse_args()
if args.go == 'runserver' or 'shell':
os.environ['FLASK_CONFIG'] = 'development'
if args.go == 'test':
os.environ['FLASK_CONFIG'] = 'testing'
app = create_app(os.getenv('FLASK_CONFIG') or 'default')
manager = Manager(app)
@manager.command
def test():
"""Run the unit tests."""
import unittest
tests = unittest.TestLoader().discover('tests')
unittest.TextTestRunner(verbosity=2).run(tests)
if __name__ == '__main__':
manager.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment