diff --git a/django/core/checks/registry.py b/django/core/checks/registry.py index 6e2657b0fb..c580c80483 100644 --- a/django/core/checks/registry.py +++ b/django/core/checks/registry.py @@ -21,8 +21,8 @@ class Tags: class CheckRegistry: def __init__(self): - self.registered_checks = [] - self.deployment_checks = [] + self.registered_checks = set() + self.deployment_checks = set() def register(self, check=None, *tags, **kwargs): """ @@ -44,11 +44,8 @@ class CheckRegistry: def inner(check): check.tags = tags - if kwargs['deploy']: - if check not in self.deployment_checks: - self.deployment_checks.append(check) - elif check not in self.registered_checks: - self.registered_checks.append(check) + checks = self.deployment_checks if kwargs['deploy'] else self.registered_checks + checks.add(check) return check if callable(check): diff --git a/django/test/utils.py b/django/test/utils.py index e1cca58b27..f86b41ae51 100644 --- a/django/test/utils.py +++ b/django/test/utils.py @@ -499,12 +499,12 @@ class override_system_checks(TestContextDecorator): def enable(self): self.old_checks = self.registry.registered_checks - self.registry.registered_checks = [] + self.registry.registered_checks = set() for check in self.new_checks: self.registry.register(check, *getattr(check, 'tags', ())) self.old_deployment_checks = self.registry.deployment_checks if self.deployment_checks is not None: - self.registry.deployment_checks = [] + self.registry.deployment_checks = set() for check in self.deployment_checks: self.registry.register(check, *getattr(check, 'tags', ()), deploy=True)