def app(): db_fd, database = tempfile.mkstemp() app = create_app({ 'DATABASE': database, 'TESTING': True, 'SECRET_KEY': 'test', }) with app.app_context(): init_db() get_db().executescript(test_data_sql()) yield app os.close(db_fd) os.unlink(app.config['DATABASE'])
def app(): app = create_app({ 'TESTING': True, 'DB_NAME': 'flask_boilerplate_test', 'DB_USER': '******', }) with app.app_context(): # Create the database in a blank state init_db() # Fill the database with mock data for tests data_file = os.path.join(os.path.dirname(__file__), 'data.sql') with open(data_file, 'rb') as f: with get_db() as con: with con.cursor() as cur: cur.execute(f.read()) yield app
def test_config(): assert not create_app().testing assert create_app({'TESTING': True}).testing
def app(): app = create_app({ 'TESTING': True, }) yield app
def test_not_passing_test_config(): app = create_app() assert app.testing is False
from flask_boilerplate import create_app app = create_app()
# -*- coding: utf-8 -*- import os from flask_boilerplate import create_app app = create_app() if __name__ == '__main__': port = int(os.environ.get('PORT', 5000)) app.run(host='0.0.0.0',port=port,debug=True)