def METHOD_NAME(db_engine):
    """
    Prepare the SQLAlchemy session object.
    We enable fast repeatable database tests by setting up the database only
    once per session (see :func:`db_engine`) and then wrapping each test
    function in a transaction that is rolled back.
    Additionally, we set a SAVEPOINT before entering the test, and if we
    detect that the test has committed (i.e. released the savepoint) we
    immediately open another. This has the effect of preventing test code from
    committing the outer transaction.
    """
    conn = db_engine.connect()
    trans = conn.begin()
    session = Session(bind=conn)
    session.begin_nested()
    @sqlalchemy.event.listens_for(session, "after_transaction_end")
    def restart_savepoint(session, transaction):
        if (  # pylint:disable=protected-access
            transaction.nested and not transaction._parent.nested
        ):
            session.begin_nested()
    try:
        yield session
    finally:
        session.close()
        trans.rollback()
        conn.close()