setup: tox prep for upcoming black updates
[git-cola.git] / test / i18n_test.py
blob36bd755354aa5f7542dda1c713b093fd1d5abeb4
1 from __future__ import absolute_import, division, unicode_literals
2 import unittest
4 from cola import i18n
5 from cola.i18n import N_
6 from cola.compat import uchr
9 class ColaI18nTestCase(unittest.TestCase):
10 """Test cases for the ColaApplication class"""
12 def tearDown(self):
13 i18n.uninstall()
15 def test_translates_noun(self):
16 """Test that strings with @@noun are translated
17 """
18 i18n.install('ja_JP')
19 expect = uchr(0x30B3) + uchr(0x30DF) + uchr(0x30C3) + uchr(0x30C8)
20 actual = N_('Commit@@verb')
21 self.assertEqual(expect, actual)
23 def test_translates_verb(self):
24 """Test that strings with @@verb are translated
25 """
26 i18n.install('de_DE')
27 expect = 'Commit aufnehmen'
28 actual = N_('Commit@@verb')
29 self.assertEqual(expect, actual)
31 def test_translates_english_noun(self):
32 """Test that English strings with @@noun are properly handled
33 """
34 i18n.install('en_US.UTF-8')
35 expect = 'Commit'
36 actual = N_('Commit@@noun')
37 self.assertEqual(expect, actual)
39 def test_translates_english_verb(self):
40 """Test that English strings with @@verb are properly handled
41 """
42 i18n.install('en_US.UTF-8')
43 expect = 'Commit'
44 actual = N_('Commit@@verb')
45 self.assertEqual(expect, actual)
47 def test_translates_random_english(self):
48 """Test that random English strings are passed through as-is
49 """
50 i18n.install('en_US.UTF-8')
51 expect = 'Random'
52 actual = N_('Random')
53 self.assertEqual(expect, actual)
55 def test_translate_push_pull_french(self):
56 i18n.install('fr_FR')
57 expect = 'Tirer'
58 actual = N_('Pull')
59 self.assertEqual(expect, actual)
61 expect = 'Pousser'
62 actual = N_('Push')
63 self.assertEqual(expect, actual)
66 if __name__ == '__main__':
67 unittest.main()