@contextmanager
def local_settings(**kwargs):
    original_values = []
    for key, value in kwargs.items():
        original_values.append([key, getattr(settings, key)])
        setattr(settings, key, value)
    try:
        yield
    finally:
        for key, value in original_values:
            setattr(settings, key, value)
Override local Django Endless Pagination settings.
dataset/ETHPy150Open frankban/django-endless-pagination/endless_pagination/tests/test_models.py/local_settings