MCPcopy
hub / github.com/django/django / enable

Method enable

django/test/utils.py:593–615  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

591 )
592
593 def enable(self):
594 self.options = {}
595 for name, operations in self.operations:
596 try:
597 # When called from SimpleTestCase.setUpClass, values may be
598 # overridden several times; cumulate changes.
599 value = self.options[name]
600 except KeyError:
601 value = list(getattr(settings, name, []))
602 for action, items in operations.items():
603 # items may be a single value or an iterable.
604 if isinstance(items, str):
605 items = [items]
606 if action == "append":
607 value += [item for item in items if item not in value]
608 elif action == "prepend":
609 value = [item for item in items if item not in value] + value
610 elif action == "remove":
611 value = [item for item in value if item not in items]
612 else:
613 raise ValueError("Unsupported action: %s" % action)
614 self.options[name] = value
615 super().enable()
616
617
618class override_system_checks(TestContextDecorator):

Callers

nothing calls this directly

Calls 2

itemsMethod · 0.45
enableMethod · 0.45

Tested by

no test coverage detected