def app(): """Create an app configured for tests.""" app = create_app({ 'TESTING': True, 'DB_URL': "postgresql://portal_user@localhost/portal_test" }) with app.app_context(): db.init_db() db.mock_db() yield app
def app(): app = create_app({ 'TESTING': True, 'DB_NAME': 'portal_test', 'DB_USER': '******', }) with app.app_context(): init_db() with open(os.path.join(os.path.dirname(__file__), 'data.sql'), 'rb') as f: with get_db() as con: with con.cursor() as cur: cur.execute(f.read()) yield app
def app(): app = create_app({ 'TESTING': True, 'DB_NAME': 'portal_test', 'DB_USER': '******', 'EMAIL': '*****@*****.**', 'PASSWORD': '******', }) with app.app_context(): init_db() with open(os.path.join(os.path.dirname(__file__), 'data.sql'), 'rb') as f: con = get_db() cur = con.cursor() cur.execute(f.read()) cur.close() con.commit() con.close() 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().executescript(_data_sql) yield app os.close(db_fd) os.unlink(db_path) @pytest.fixture def client(app): return app.test_client() @pytest.fixture def runner(app): return app.test_cli_runner()