def client(): test_config = { "SQLALCHEMY_DATABASE_URL": "sqlite:///./test-sqlite.db", "ENV": "development", "DEBUG": True, "SECRET_KEY": "would-get-from-env-file" } app = create_app(test_config) with app.test_client() as client: yield client # remove data in test database from project.database import clear_db clear_db()
def app(): """Create and configure a new app instance for each test.""" # create a temporary file to isolate the database for each test db_fd, db_path = tempfile.mkstemp() # create the app with common test config app = create_app({ 'TESTING': True, 'DATABASE': db_path, }) # create the database and load test data with app.app_context(): init_db() get_db().executescript(_data_sql) yield app # close and remove the temporary database os.close(db_fd) os.unlink(db_path)
def app(): app = create_app() app.debug = True return app.test_client()
from project.app import create_app app = create_app()
# -*- coding: utf-8 -*- from project.app import create_app application = create_app() if __name__ == "__main__": application.run()
#!/usr/bin/env python # coding=utf-8 from project.app import create_app application = create_app()
from project.app import create_app if __name__ == "__main__": app = create_app() app.run(debug=True)
"""Create an application instance.""" from flask.helpers import get_debug_flag from project.app import create_app from project.settings import DevConfig, ProdConfig # CONFIG = DevConfig if get_debug_flag() else ProdConfig CONFIG = DevConfig app = create_app(CONFIG)
from project.app import create_app config = { "SQLALCHEMY_DATABASE_URL": "sqlite:///./sqlite.db", "ENV": "development", "DEBUG": True, "SECRET_KEY": "would-get-from-env-file" } app = create_app(config) app.run(debug=True)
def app(): from project._config import Config config = Config({}) app = create_app(config) return app
def app(): test_config = TestingConfig() _app = create_app(test_config) return _app
def run(): return create_app(cli=True, testing=True if sys.argv[1] == 'test' else False)
import os from project.app import create_app app = create_app(os.environ.get("ENV") or "default") if __name__ == "__main__": app.run(debug=True)