def app(): """An application for the tests.""" _app = create_app(TestConfig) ctx = _app.test_request_context() ctx.push() yield _app ctx.pop()
""" To run a local development server: FLASK_TRAP_BAD_REQUEST_ERRORS=1 FLASK_DEBUG=1 FLASK_APP=src/reader/app/wsgi.py \ READER_DB=db.sqlite flask run -h 0.0.0.0 -p 8000 """ import os from reader.app import create_app app = create_app(os.environ['READER_DB']) app.config['TRAP_BAD_REQUEST_ERRORS'] = bool(os.environ.get('FLASK_TRAP_BAD_REQUEST_ERRORS', ''))
# -*- coding: utf-8 -*- """Create an application instance.""" from flask.helpers import get_debug_flag from reader.app import create_app from reader.settings import DevConfig, ProdConfig CONFIG = DevConfig if get_debug_flag() else ProdConfig app = create_app(CONFIG)
def test_production_config(): """Production config.""" app = create_app(ProdConfig) assert app.config['ENV'] == 'prod' assert app.config['DEBUG'] is False assert app.config['DEBUG_TB_ENABLED'] is False
def test_dev_config(): """Development config.""" app = create_app(DevConfig) assert app.config['ENV'] == 'dev' assert app.config['DEBUG'] is True
""" To run a local development server: FLASK_DEBUG=1 FLASK_TRAP_BAD_REQUEST_ERRORS=1 \ FLASK_APP=src/reader/app/wsgi.py \ READER_DB=db.sqlite flask run -h 0.0.0.0 -p 8000 """ import os import reader from reader.app import create_app app = create_app(os.environ[reader._DB_ENVVAR], os.environ.get(reader._PLUGIN_ENVVAR, '').split()) app.config['TRAP_BAD_REQUEST_ERRORS'] = bool( os.environ.get('FLASK_TRAP_BAD_REQUEST_ERRORS', ''))