MCPcopy Index your code
hub / github.com/python/cpython / test_translations

Method test_translations

Lib/test/test_tools/test_msgfmt.py:72–92  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

70 self.assertEqual(hash_table_offset, 0)
71
72 def test_translations(self):
73 with open(data_dir / 'general.mo', 'rb') as f:
74 t = GNUTranslations(f)
75
76 self.assertEqual(t.gettext('foo'), 'foo')
77 self.assertEqual(t.gettext('bar'), 'baz')
78 self.assertEqual(t.pgettext('abc', 'foo'), 'bar')
79 self.assertEqual(t.pgettext('xyz', 'foo'), 'bar')
80 self.assertEqual(t.gettext('Multilinestring'), 'Multilinetranslation')
81 self.assertEqual(t.gettext('"escapes"'), '"translated"')
82 self.assertEqual(t.gettext('\n newlines \n'), '\n translated \n')
83 self.assertEqual(t.ngettext('One email sent.', '%d emails sent.', 1),
84 'One email sent.')
85 self.assertEqual(t.ngettext('One email sent.', '%d emails sent.', 2),
86 '%d emails sent.')
87 self.assertEqual(t.npgettext('abc', 'One email sent.',
88 '%d emails sent.', 1),
89 'One email sent.')
90 self.assertEqual(t.npgettext('abc', 'One email sent.',
91 '%d emails sent.', 2),
92 '%d emails sent.')
93
94 def test_po_with_bom(self):
95 with temp_cwd():

Callers

nothing calls this directly

Calls 7

gettextMethod · 0.95
pgettextMethod · 0.95
ngettextMethod · 0.95
npgettextMethod · 0.95
GNUTranslationsClass · 0.90
openFunction · 0.50
assertEqualMethod · 0.45

Tested by

no test coverage detected