예제 #1
0
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
예제 #2
0
파일: conftest.py 프로젝트: crypex/poppet
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
예제 #3
0
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
예제 #4
0
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