Ottomata has uploaded a new change for review. https://gerrit.wikimedia.org/r/254893
Change subject: Import EventLoggingService in test properly, don't use setdefault for caching validator ...................................................................... Import EventLoggingService in test properly, don't use setdefault for caching validator Change-Id: I508d609744635e0aa1d1181946a9ee6816b38c77 --- M eventlogging/schema.py M tests/test_service.py 2 files changed, 8 insertions(+), 5 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/eventlogging refs/changes/93/254893/1 diff --git a/eventlogging/schema.py b/eventlogging/schema.py index 9f14c63..ae3ab91 100644 --- a/eventlogging/schema.py +++ b/eventlogging/schema.py @@ -209,10 +209,13 @@ # Get validator for this schema out of the cache, or # create a new validator and save it in the cache. - schema_validator_cache.setdefault( - scid, - get_validator(schema)(schema) - ).validate(event) + if scid in schema_validator_cache: + validator = schema_validator_cache[scid] + else: + validator = get_validator(schema)(schema) + schema_validator_cache[scid] = validator + + validator.validate(event) def get_validator(schema): diff --git a/tests/test_service.py b/tests/test_service.py index dd83ea2..f16df0d 100644 --- a/tests/test_service.py +++ b/tests/test_service.py @@ -8,7 +8,7 @@ import copy from tornado.testing import AsyncHTTPTestCase -from eventlogging import EventLoggingService +from eventlogging.service import EventLoggingService import json from .fixtures import SchemaTestMixin -- To view, visit https://gerrit.wikimedia.org/r/254893 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I508d609744635e0aa1d1181946a9ee6816b38c77 Gerrit-PatchSet: 1 Gerrit-Project: eventlogging Gerrit-Branch: master Gerrit-Owner: Ottomata <o...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits