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:
|
class CheckRegistry:
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.registered_checks = []
|
self.registered_checks = set()
|
||||||
self.deployment_checks = []
|
self.deployment_checks = set()
|
||||||
|
|
||||||
def register(self, check=None, *tags, **kwargs):
|
def register(self, check=None, *tags, **kwargs):
|
||||||
"""
|
"""
|
||||||
|
@ -44,11 +44,8 @@ class CheckRegistry:
|
||||||
|
|
||||||
def inner(check):
|
def inner(check):
|
||||||
check.tags = tags
|
check.tags = tags
|
||||||
if kwargs['deploy']:
|
checks = self.deployment_checks if kwargs['deploy'] else self.registered_checks
|
||||||
if check not in self.deployment_checks:
|
checks.add(check)
|
||||||
self.deployment_checks.append(check)
|
|
||||||
elif check not in self.registered_checks:
|
|
||||||
self.registered_checks.append(check)
|
|
||||||
return check
|
return check
|
||||||
|
|
||||||
if callable(check):
|
if callable(check):
|
||||||
|
|
|
@ -499,12 +499,12 @@ class override_system_checks(TestContextDecorator):
|
||||||
|
|
||||||
def enable(self):
|
def enable(self):
|
||||||
self.old_checks = self.registry.registered_checks
|
self.old_checks = self.registry.registered_checks
|
||||||
self.registry.registered_checks = []
|
self.registry.registered_checks = set()
|
||||||
for check in self.new_checks:
|
for check in self.new_checks:
|
||||||
self.registry.register(check, *getattr(check, 'tags', ()))
|
self.registry.register(check, *getattr(check, 'tags', ()))
|
||||||
self.old_deployment_checks = self.registry.deployment_checks
|
self.old_deployment_checks = self.registry.deployment_checks
|
||||||
if self.deployment_checks is not None:
|
if self.deployment_checks is not None:
|
||||||
self.registry.deployment_checks = []
|
self.registry.deployment_checks = set()
|
||||||
for check in self.deployment_checks:
|
for check in self.deployment_checks:
|
||||||
self.registry.register(check, *getattr(check, 'tags', ()), deploy=True)
|
self.registry.register(check, *getattr(check, 'tags', ()), deploy=True)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue