testing: Flush API_KEYS before every test.

This makes our test performance for each test more consistent.
This commit is contained in:
Umair Khan 2017-03-22 15:45:39 +05:00 committed by Tim Abbott
parent ff8ab054da
commit 804c62045f
2 changed files with 7 additions and 0 deletions

View File

@ -64,6 +64,11 @@ import six
API_KEYS = {} # type: Dict[Text, Text] API_KEYS = {} # type: Dict[Text, Text]
def flush_caches_for_testing():
# type: () -> None
global API_KEYS
API_KEYS = {}
class UploadSerializeMixin(SerializeMixin): class UploadSerializeMixin(SerializeMixin):
""" """
We cannot use override_settings to change upload directory because We cannot use override_settings to change upload directory because

View File

@ -14,6 +14,7 @@ from django.test.signals import template_rendered
from zerver.lib import test_classes, test_helpers from zerver.lib import test_classes, test_helpers
from zerver.lib.cache import bounce_key_prefix_for_testing from zerver.lib.cache import bounce_key_prefix_for_testing
from zerver.lib.test_classes import flush_caches_for_testing
from zerver.lib.sqlalchemy_utils import get_sqlalchemy_connection from zerver.lib.sqlalchemy_utils import get_sqlalchemy_connection
from zerver.lib.test_helpers import ( from zerver.lib.test_helpers import (
get_all_templates, write_instrumentation_reports, get_all_templates, write_instrumentation_reports,
@ -111,6 +112,7 @@ def run_test(test, result):
test_name = full_test_name(test) test_name = full_test_name(test)
bounce_key_prefix_for_testing(test_name) bounce_key_prefix_for_testing(test_name)
flush_caches_for_testing()
if not hasattr(test, "_pre_setup"): if not hasattr(test, "_pre_setup"):
# test_name is likely of the form unittest.loader.ModuleImportFailure.zerver.tests.test_upload # test_name is likely of the form unittest.loader.ModuleImportFailure.zerver.tests.test_upload