def test_gettext_values(self): # test with no value expansion self.assertEqual(gtcache.gettext(INPUT), OUTPUT) # test with old value expansion self.assertEqual(gtcache.gettext(INPUT) % {"countfiles": 1, "countvideos": 2}, OUTPUT % {"countfiles": 1, "countvideos": 2}) # test with value expansion done by gtcache.gettext self.assertEqual(gtcache.gettext(INPUT, {"countfiles": 1, "countvideos": 2}), OUTPUT % {"countfiles": 1, "countvideos": 2})
def test_gettext_values_failures(self): # try gettext with a bad translation. the string is fine, but # the translated version of the string is missing the d # characters which causes a Python formatting syntax error. input2 = "bad parsed %(countfiles)d files - found %(countvideos)d videos" # first we call gettext on the string by itself--this is fine, # so we should get the translated version of the string. self.assertEqual(gtcache.gettext(input2), u'bad %(countfiles) fichiers analys\xe9s - %(countvideos) vid\xe9os trouv\xe9es') # now we pass in a values dict which will kick up a ValueError # when trying to expand the values. that causes gettext to # return the english form of the string with values expanded. self.assertEqual(gtcache.gettext(input2, {"countfiles": 1, "countvideos": 2}), input2 % {"countfiles": 1, "countvideos": 2})
def test_gettext_values(self): # test with no value expansion self.assertEqual(gtcache.gettext(INPUT), OUTPUT) # test with old value expansion self.assertEqual( gtcache.gettext(INPUT) % { "countfiles": 1, "countvideos": 2 }, OUTPUT % { "countfiles": 1, "countvideos": 2 }) # test with value expansion done by gtcache.gettext self.assertEqual( gtcache.gettext(INPUT, { "countfiles": 1, "countvideos": 2 }), OUTPUT % { "countfiles": 1, "countvideos": 2 })
def test_gettext_values_failures(self): # try gettext with a bad translation. the string is fine, but # the translated version of the string is missing the d # characters which causes a Python formatting syntax error. input2 = ("bad parsed %(countfiles)d files - " "found %(countvideos)d videos") # first we call gettext on the string by itself--this is fine, # so we should get the translated version of the string. self.assertEqual(gtcache.gettext(input2), (u'bad %(countfiles) fichiers analys\xe9s - ' u'%(countvideos) vid\xe9os trouv\xe9es')) # now we pass in a values dict which will kick up a ValueError # when trying to expand the values. that causes gettext to # return the english form of the string with values expanded. self.assertEqual( gtcache.gettext(input2, { "countfiles": 1, "countvideos": 2 }), input2 % { "countfiles": 1, "countvideos": 2 })
def test_gettext(self): self.assertEqual(gtcache.gettext("OK"), u'Valider') self.assertEqual(gtcache.gettext("Channels"), u'Cha\xeenes')