def enable(self):
            self.options = {}
            for name, operations in self.operations:
                try:
                    # When called from SimpleTestCase._pre_setup, values may be
                    # overridden several times; cumulate changes.
                    value = self.options[name]
                except __HOLE__:
                    value = list(getattr(settings, name, []))
                for action, items in operations.items():
                    # items my be a single value or an iterable.
                    if isinstance(items, six.string_types):
                        items = [items]
                    if action == 'append':
                        value = value + [item for item in items if item not in value]
                    elif action == 'prepend':
                        value = [item for item in items if item not in value] + value
                    elif action == 'remove':
                        value = [item for item in value if item not in items]
                    else:
                        raise ValueError("Unsupported action: %s" % action)
                self.options[name] = value
            super(modify_settings, self).enable()
dataset/ETHPy150Open st4lk/django-rest-social-auth/tests/utils.py/modify_settings.enable