def session(db, request):
    """ Roll back db in between tests using nested session.
    This fixture should be used for any test that updates the
    database.
    :param db: Pytest fixture
    :return: None
    """
    db.session.begin_nested()

    def teardown():
        db.session.rollback()

    request.addfinalizer(teardown)

    return db.session