2013-05-19 17:44:46 +08:00
|
|
|
from threading import local
|
|
|
|
|
|
|
|
|
|
|
|
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._accepted = {}
|
2013-05-19 18:43:34 +08:00
|
|
|
trans_real._checked_languages = {}
|
2013-05-19 17:44:46 +08:00
|
|
|
|
|
|
|
def tearDown(self):
|
|
|
|
self.flush_caches()
|
|
|
|
super(TransRealMixin, self).tearDown()
|