Used sets for CheckRegistry.registered_checks and deployment_checks.
This commit is contained in:
parent
c0f4c60edd
commit
481ba33cd2
|
@ -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):
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in New Issue