def app(): app = create_app() app.config.update(DEBUG=True, SERVER_NAME=getenv('RUNNER_IP').strip(), HOST=getenv('RUNNER_IP').strip()) return app
def sample_app(): app = create_app() with app.app_context(): db.create_all() return app
def client(): app = create_app('testing') client = app.test_client() with app.app_context(): db.create_all() yield client
def setUp(self): super(TestUserModel, self).setUp() self.app = create_app('testing') self.app_context = self.app.app_context() self.app_context.push() db.create_all()
def client(): app = create_app() context = app.app_context() context.push() yield app.test_client() context.pop() return app
def app(): import sys sys.path.append('.') from sample_app import create_app app = create_app() app.debug = True app.testing = True # manually add flask-debug from flask_debug import Debug Debug(app) return app
def app(): db_fd, db_path = tempfile.mkstemp() app = create_app({ 'TESTING': True, 'DATABASE': db_path, }) with app.app_context(): init_db() get_db().executescript(_data_sql) yield app os.close(db_fd) os.unlink(db_path)
# under normal circumstances, this script would not be necessary. the # sample_application would have its own setup.py and be properly installed; # however since it is not bundled in the sdist package, we need some hacks # to make it work import os import sys print(os.path.dirname(__name__)) sys.path.append(os.path.dirname(__name__)) from sample_app import create_app # create an app instance app = create_app()
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) from flask_script import Manager, Server # NOQA from flask_script.commands import Shell, ShowUrls # NOQA from flask_migrate import MigrateCommand, Migrate # NOQA from sample_app import create_app # NOQA from sample_app.database import db # NOQA COV = None if os.environ.get('FLASK_COVERAGE'): import coverage COV = coverage.coverage(branch=True, include='sample/*') COV.start() app = create_app(os.getenv('FLASK_CONFIG') or 'default') manager = Manager(app) migrate = Migrate(app, db) def make_shell_context(): return dict(app=app, db=db) @manager.command def test(coverage=False): """Run the unit test.""" if coverage and not os.environ.get('FLASK_COVERAGE'): import sys os.environ['FLASK_COVERAGE'] = '1'
def app(): app = create_app() return app
#!/usr/bin/env python #-*- coding:utf-8 -*- from flask.ext.script import Manager from sample_app import create_app, db, models app = create_app() manager = Manager(app) @manager.command def syncdb(): db.create_all(app=app) @manager.shell def make_shell_context(): return dict(app=app, db=db, models=models) if __name__ == '__main__': manager.run()
import os from sample_app import create_app app = create_app(os.getenv('APP_SETTINGS') or 'default') if __name__ == '__main__': app.run()
def test_config(): assert not create_app().testing assert create_app({'TESTING': True}).testing
import sample_app app = sample_app.create_app()