1 # -*- encoding: utf-8 -*-
2 from __future__
import unicode_literals
5 sip
.setapi('QString', 1)
9 from PyQt4
import QtCore
12 from cola
.i18n
import N_
13 from cola
.compat
import unichr
16 class ColaI18nTestCase(unittest
.TestCase
):
17 """Test cases for the ColaApplication class"""
22 def test_translates_noun(self
):
23 """Test that strings with @@noun are translated
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
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
42 i18n
.install('en_US.UTF-8')
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
50 i18n
.install('en_US.UTF-8')
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
58 i18n
.install('en_US.UTF-8')
61 self
.assertEqual(expect
, actual
)
63 def test_guards_against_qstring(self
):
64 """Test that random QString is passed through as-is
66 i18n
.install('en_US.UTF-8')
68 actual
= i18n
.gettext(QtCore
.QString('Random'))
69 self
.assertEqual(expect
, actual
)
72 if __name__
== '__main__':