def session(db, request): """Creates a new database session for a test.""" connection = db.engine.connect() transaction = connection.begin() options = dict(bind=connection, binds={}) session = db.create_scoped_session(options=options) db.session = session init_data(session) def teardown(): transaction.rollback() connection.close() session.remove() request.addfinalizer(teardown) return session
def session(db, request): """Creates a new database session for a test.""" #connection = db.engine.connect() #transaction = connection.begin() #options = dict(bind=connection, binds={}) #session = db.create_session(options=options) #db.session = session init_data(db.session) def teardown(): #transaction.rollback() #connection.close() #session.remove() pass request.addfinalizer(teardown) return db.session