cubicweb/req.py
branch3.24
changeset 11825 52acf0dbf4cd
parent 11824 d7ecf6dab085
child 11868 d5181d7f1389
--- a/cubicweb/req.py	Thu Nov 17 10:53:04 2016 +0100
+++ b/cubicweb/req.py	Thu Nov 17 10:15:11 2016 +0100
@@ -96,7 +96,15 @@
         Raises :exc:`KeyError` if translation doesn't exist.
         """
         self.lang = lang
-        gettext, pgettext = self.vreg.config.translations[lang]
+        try:
+            gettext, pgettext = self.vreg.config.translations[lang]
+        except KeyError:
+            assert self.vreg.config.mode == 'test'
+            gettext = text_type
+
+            def pgettext(x, y):
+                return text_type(y)
+
         # use _cw.__ to translate a message without registering it to the catalog
         self._ = self.__ = gettext
         self.pgettext = pgettext