summaryrefslogtreecommitdiff
path: root/tests/i18n/__init__.py
blob: c5aaa31fe31f3ccf47d5dba90b053f8f6ca947ea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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 = {}
        trans_real._checked_languages = {}

    def tearDown(self):
        self.flush_caches()
        super(TransRealMixin, self).tearDown()