summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDoug Beck <doug@douglasbeck.com>2014-04-30 18:04:30 +0200
committerClaude Paroz <claude@2xlibre.net>2014-04-30 18:36:25 +0200
commita5f6cbce07b5f3ab48d931e3fd1883c757fb9b45 (patch)
tree5f1ef1df3577e76163fde07d90730c50d62c8dd6 /tests
parent7c54f8cced37313572d72f59bd2ef7ce12aa8fe1 (diff)
Refactored DjangoTranslation class
Also fixes #18192 and #21055.
Diffstat (limited to 'tests')
-rw-r--r--tests/i18n/tests.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/i18n/tests.py b/tests/i18n/tests.py
index eee9896266..13198831a0 100644
--- a/tests/i18n/tests.py
+++ b/tests/i18n/tests.py
@@ -4,6 +4,7 @@ from __future__ import unicode_literals
from contextlib import contextmanager
import datetime
import decimal
+import gettext as gettext_module
from importlib import import_module
import os
import pickle
@@ -1338,3 +1339,26 @@ class CountrySpecificLanguageTests(TestCase):
r.META = {'HTTP_ACCEPT_LANGUAGE': 'pt-pt,en-US;q=0.8,en;q=0.6,ru;q=0.4'}
lang = get_language_from_request(r)
self.assertEqual('pt-br', lang)
+
+
+class TranslationFilesMissing(TestCase):
+
+ def setUp(self):
+ super(TranslationFilesMissing, self).setUp()
+ self.gettext_find_builtin = gettext_module.find
+
+ def tearDown(self):
+ gettext_module.find = self.gettext_find_builtin
+ super(TranslationFilesMissing, self).tearDown()
+
+ def patchGettextFind(self):
+ gettext_module.find = lambda *args, **kw: None
+
+ def test_failure_finding_default_mo_files(self):
+ '''
+ Ensure IOError is raised if the default language is unparseable.
+ Refs: #18192
+ '''
+ self.patchGettextFind()
+ trans_real._translations = {}
+ self.assertRaises(IOError, activate, 'en')