Merge branch 'dag-selection'
[git-cola.git] / test / i18n_test.py
blob7154d4026d52fd91a24a410b7e596bd790eae336
1 # -*- encoding: utf-8 -*-
2 from __future__ import unicode_literals
4 import sip
5 sip.setapi('QString', 1)
7 import unittest
9 from PyQt4 import QtCore
11 from cola import i18n
12 from cola.i18n import N_
13 from cola.compat import unichr
16 class ColaI18nTestCase(unittest.TestCase):
17 """Test cases for the ColaApplication class"""
19 def tearDown(self):
20 i18n.uninstall()
22 def test_translates_noun(self):
23 """Test that strings with @@noun are translated
24 """
25 i18n.install('ja_JP')
26 expect = (unichr(0x30b3) + unichr(0x30df) +
27 unichr(0x30c3) + unichr(0x30c8))
28 actual = N_('Commit@@verb')
29 self.assertEqual(expect, actual)
31 def test_translates_verb(self):
32 """Test that strings with @@verb are translated
33 """
34 i18n.install('de_DE')
35 expect = 'Version aufnehmen'
36 actual = N_('Commit@@verb')
37 self.assertEqual(expect, actual)
39 def test_translates_english_noun(self):
40 """Test that English strings with @@noun are properly handled
41 """
42 i18n.install('en_US.UTF-8')
43 expect = 'Commit'
44 actual = N_('Commit@@noun')
45 self.assertEqual(expect, actual)
47 def test_translates_english_verb(self):
48 """Test that English strings with @@verb are properly handled
49 """
50 i18n.install('en_US.UTF-8')
51 expect = 'Commit'
52 actual = N_('Commit@@verb')
53 self.assertEqual(expect, actual)
55 def test_translates_random_english(self):
56 """Test that random English strings are passed through as-is
57 """
58 i18n.install('en_US.UTF-8')
59 expect = 'Random'
60 actual = N_('Random')
61 self.assertEqual(expect, actual)
63 def test_guards_against_qstring(self):
64 """Test that random QString is passed through as-is
65 """
66 i18n.install('en_US.UTF-8')
67 expect = 'Random'
68 actual = i18n.gettext(QtCore.QString('Random'))
69 self.assertEqual(expect, actual)
72 if __name__ == '__main__':
73 unittest.main()