Exemplo n.º 1
0
 def test_resets_trans_real(self):
     trans_real._translations = {'foo': 'bar'}
     trans_real._default = 1
     trans_real._active = False
     autoreload.reset_translations()
     self.assertEqual(trans_real._translations, {})
     self.assertIsNone(trans_real._default)
     self.assertIsInstance(trans_real._active, _thread._local)
Exemplo n.º 2
0
 def process_request(request):
     locale_mtime = getmtime(get_locale_path())
     try:
         thread_local = threading.local
         if locale_mtime > thread_local.locale_mtime:
             thread_local.locale_mtime = locale_mtime
             reset_translations()
     except:
         pass
Exemplo n.º 3
0
def reloader_thread():
    ensure_echo_on()
    if USE_INOTIFY:
        fn = inotify_code_changed
    else:
        fn = code_changed
    while RUN_RELOADER:
        change = fn()
        if change == FILE_MODIFIED:
            auto_collectstatic()
            sys.exit(3)  # force reload
        elif change == I18N_MODIFIED:
            reset_translations()
        time.sleep(1)
Exemplo n.º 4
0
 def test_resets_gettext(self):
     gettext._translations = {'foo': 'bar'}
     autoreload.reset_translations()
     self.assertEqual(gettext._translations, {})