diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2014-01-26 15:28:33 +0100 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2014-01-27 22:02:07 +0100 |
| commit | b87bc461c89f2006f0b27c7240fb488fac32bed1 (patch) | |
| tree | dc761e81a9fdaa3e7e2500f0f605f4bc4eeda44f /django | |
| parent | b951a7fbc12045eff104940dafaec308a543ead2 (diff) | |
Removed TransRealMixin.
Fixed #21688. Refs https://github.com/django/django/pull/1147.
Diffstat (limited to 'django')
| -rw-r--r-- | django/test/signals.py | 12 | ||||
| -rw-r--r-- | django/test/utils.py | 17 |
2 files changed, 9 insertions, 20 deletions
diff --git a/django/test/signals.py b/django/test/signals.py index 66b96a4eb1..5cfc9f3845 100644 --- a/django/test/signals.py +++ b/django/test/signals.py @@ -42,6 +42,9 @@ def update_installed_apps(**kwargs): # Rebuild app_template_dirs cache. from django.template.loaders import app_directories as mod mod.app_template_dirs = mod.calculate_app_template_dirs() + # Rebuild translations cache. + from django.utils.translation import trans_real + trans_real._translations = {} @receiver(setting_changed) @@ -97,11 +100,14 @@ def clear_serializers_cache(**kwargs): @receiver(setting_changed) def language_changed(**kwargs): - if kwargs['setting'] in ('LOCALE_PATHS', 'LANGUAGE_CODE'): + if kwargs['setting'] in {'LANGUAGES', 'LANGUAGE_CODE', 'LOCALE_PATHS'}: from django.utils.translation import trans_real trans_real._default = None - if kwargs['setting'] == 'LOCALE_PATHS': - trans_real._translations = {} + trans_real._active = threading.local() + if kwargs['setting'] in {'LANGUAGES', 'LOCALE_PATHS'}: + from django.utils.translation import trans_real + trans_real._translations = {} + trans_real.check_for_language.cache_clear() @receiver(setting_changed) diff --git a/django/test/utils.py b/django/test/utils.py index bc3f823a3a..393da3b17c 100644 --- a/django/test/utils.py +++ b/django/test/utils.py @@ -2,7 +2,6 @@ from contextlib import contextmanager import logging import re import sys -from threading import local import time from unittest import skipUnless import warnings @@ -502,22 +501,6 @@ def patch_logger(logger_name, log_level): setattr(logger, log_level, orig) -class TransRealMixin(object): - """This is the only way to reset the translation machinery. Otherwise - the test suite occasionally fails because of global state pollution - between tests.""" - def flush_caches(self): - from django.utils.translation import trans_real - trans_real._translations = {} - trans_real._active = local() - trans_real._default = None - trans_real.check_for_language.cache_clear() - - def tearDown(self): - self.flush_caches() - super(TransRealMixin, self).tearDown() - - # On OSes that don't provide tzset (Windows), we can't set the timezone # in which the program runs. As a consequence, we must skip tests that # don't enforce a specific timezone (with timezone.override or equivalent), |
