MCPcopy
hub / github.com/tornadoweb/tornado / test_gettext

Method test_gettext

tornado/test/locale_test.py:60–75  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

58 shutil.rmtree(tmpdir)
59
60 def test_gettext(self):
61 tornado.locale.load_gettext_translations(
62 os.path.join(os.path.dirname(__file__), "gettext_translations"),
63 "tornado_test",
64 )
65 locale = tornado.locale.get("fr_FR")
66 self.assertTrue(isinstance(locale, tornado.locale.GettextLocale))
67 self.assertEqual(locale.translate("school"), "\u00e9cole")
68 self.assertEqual(locale.pgettext("law", "right"), "le droit")
69 self.assertEqual(locale.pgettext("good", "right"), "le bien")
70 self.assertEqual(locale.pgettext("organization", "club", "clubs", 1), "le club")
71 self.assertEqual(
72 locale.pgettext("organization", "club", "clubs", 2), "les clubs"
73 )
74 self.assertEqual(locale.pgettext("stick", "club", "clubs", 1), "le b\xe2ton")
75 self.assertEqual(locale.pgettext("stick", "club", "clubs", 2), "les b\xe2tons")
76
77
78class LocaleDataTest(unittest.TestCase):

Callers

nothing calls this directly

Calls 4

joinMethod · 0.80
getMethod · 0.45
translateMethod · 0.45
pgettextMethod · 0.45

Tested by

no test coverage detected