def test_config(): assert not create_app().testing assert create_app({'TESTING': True}).testing assert create_app({'STARTUP_COALESCING_SECONDS': 5}) is not None assert create_app({'STARTUP_COALESCING_SECONDS': 15}) is not None with pytest.raises(ValueError): create_app({'STARTUP_COALESCING_SECONDS': 4}) with pytest.raises(ValueError): create_app({'STARTUP_COALESCING_SECONDS': 16})
def app(): app = create_app({ 'TESTING': True, 'SECRET_KEY': 'testing', 'STARTUP_COALESCING_SECONDS': 5, }) yield 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().execute(_data_sql, multi=True) yield app os.close(db_fd) os.unlink(db_path)
from flask import Flask from flask_script import Manager from homework import create_app app = create_app() manager = Manager(app) if __name__ == '__main__': manager.run()
from homework import create_app app = create_app() if __name__ == "__main__": app = create_app({'SHOWINFO': True}) app.run(debug=True)
def test_config(): assert not create_app().testing assert create_app({'TESTING': True}).testing