Ejemplo n.º 1
0
 def test___reduce__(self):
     klass = self._getTargetClass()
     inst = self._makeOne('msgid', default='default', domain='domain',
                          mapping='mapping')
     result = inst.__reduce__()
     self.assertEqual(result, (klass, (u('msgid'), 'domain', u('default'),
                                       'mapping', None)))
Ejemplo n.º 2
0
 def test_interpolate_subsitution_more_than_once(self):
     mapping = {"name": "Zope", "version": 3}
     inst = self._makeOne(
         u("This is $name version ${version}. ${name} $version!"),
         mapping=mapping)
     result = inst.interpolate()
     self.assertEqual(result, u('This is Zope version 3. Zope 3!'))
Ejemplo n.º 3
0
 def test_msgctxt_no_translation(self):
     translations = DummyTranslations(u('button\x04p\xf8f'))
     result = self._callFUT(
         translations, u('p\xf8f'), 'plural', 1, context='button')
     self.assertEqual(translations.params,
                      (u('button\x04p\xf8f'), 'plural', 1))
     self.assertEqual(result, u('p\xf8f'))
Ejemplo n.º 4
0
 def test_msgctxt_override(self):
     translations = DummyTranslations('result')
     tstring = DummyTranslationString(u('p\xf8f'), context='other')
     result = self._callFUT(translations, tstring, None, context='button')
     self.assertEqual(translations.params,
                      ('messages', u('button\x04p\xf8f'),))
     self.assertEqual(result, 'result')
Ejemplo n.º 5
0
 def test_interpolate_missing_not_interpolated(self):
     mapping = {"name": "Zope", "version": 3}
     inst = self._makeOne(
         u("This is $name $version. $unknown $$name $${version}."),
         mapping=mapping)
     result = inst.interpolate()
     self.assertEqual(result,
                      u('This is Zope 3. $unknown $$name $${version}.'))
Ejemplo n.º 6
0
 def test___getstate__(self):
     inst = self._makeOne('msgid',
                          default='default',
                          domain='domain',
                          mapping='mapping')
     result = inst.__getstate__()
     self.assertEqual(result,
                      (u('msgid'), 'domain', u('default'), 'mapping', None))
Ejemplo n.º 7
0
 def test_interpolate_double_dollar_escape(self):
     mapping = {"name": "Zope", "version": 3}
     inst = self._makeOne('$$name', mapping=mapping)
     result = inst.interpolate()
     self.assertEqual(result, u('$$name'))
Ejemplo n.º 8
0
 def test_interpolate_substitution(self):
     mapping = {"name": "Zope", "version": 3}
     inst = self._makeOne('This is $name version ${version}.',
                           mapping=mapping)
     result = inst.interpolate()
     self.assertEqual(result, u('This is Zope version 3.'))
Ejemplo n.º 9
0
 def test_msgctxt_no_translation_found(self):
     translations = DummyTranslations(u('button\x04p\xf8f'))
     tstring = DummyTranslationString(u('p\xf8f'), context='button')
     result = self._callFUT(translations, tstring, None)
     self.assertEqual(result, u('p\xf8f'))
Ejemplo n.º 10
0
 def test_msgctxt_no_translation_found(self):
     input = u('p\xf8f')
     translations = DummyTranslations(input)
     result = self._callFUT(translations, input, None, 'button')
     self.assertEqual(result, u('p\xf8f'))
Ejemplo n.º 11
0
 def test_msgctxt(self):
     translations = DummyTranslations('result')
     result = self._callFUT(translations, u('p\xf8f'), None, 'button')
     self.assertEqual(translations.params, (u('button\x04p\xf8f'),))
     self.assertEqual(result, 'result')
Ejemplo n.º 12
0
 def test_msgid_text_type_translator_is_None(self):
     msgid = u('foo')
     translate = self._makeOne(None)
     result = translate(msgid)
     self.assertEqual(result, u('foo'))
Ejemplo n.º 13
0
 def test___getstate__(self):
     inst = self._makeOne('msgid', default='default', domain='domain',
                          mapping='mapping')
     result = inst.__getstate__()
     self.assertEqual(result,
                      (u('msgid'), 'domain', u('default'), 'mapping', None))
Ejemplo n.º 14
0
 def test_interpolate_passed_translated(self):
     mapping = {"name": "Zope", "version": 3}
     inst = self._makeOne(u("This is ${name}"), mapping = mapping)
     result = inst.interpolate('That is ${name}')
     self.assertEqual(result, u('That is Zope'))
Ejemplo n.º 15
0
 def test_interpolate_missing_mapping(self):
     inst = self._makeOne(u("This is ${name}"))
     result = inst.interpolate()
     self.assertEqual(result, u('This is ${name}'))