import functools


def database(request, mongodb_instance):
    """
    Return a MongoDB database suitable for testing auth. Remove the
    collection between every test.
    """
    database = mongodb_instance.get_connection().sessions_test
    request.addfinalizer(functools.partial(database.sessions.delete_many, {}))
    return database