def session(db, request):
    """
    Creates a new database session with (with working transaction)
    for test duration.
    """
    db.session.begin_nested()
    yield db.session
    db.session.rollback()

    Creates a new database session with (with working transaction)
    for test duration.
    
lemur/tests/conftest.py