1 # -*- encoding: utf-8 -*-
4 from PyQt4
import QtCore
7 from cola
.i18n
import N_
10 class ColaI18nTestCase(unittest
.TestCase
):
11 """Test cases for the ColaApplication class"""
16 def test_translates_noun(self
):
17 """Test that strings with @@noun are translated
20 expect
= (unichr(0x30b3) + unichr(0x30df) +
21 unichr(0x30c3) + unichr(0x30c8))
22 actual
= N_('Commit@@verb')
23 self
.assertEqual(expect
, actual
)
25 def test_translates_verb(self
):
26 """Test that strings with @@verb are translated
29 expect
= 'Version aufnehmen'
30 actual
= N_('Commit@@verb')
31 self
.assertEqual(expect
, actual
)
33 def test_translates_english_noun(self
):
34 """Test that English strings with @@noun are properly handled
36 i18n
.install('en_US.UTF-8')
38 actual
= N_('Commit@@noun')
39 self
.assertEqual(expect
, actual
)
41 def test_translates_english_verb(self
):
42 """Test that English strings with @@verb are properly handled
44 i18n
.install('en_US.UTF-8')
46 actual
= N_('Commit@@verb')
47 self
.assertEqual(expect
, actual
)
49 def test_translates_random_english(self
):
50 """Test that random English strings are passed through as-is
52 i18n
.install('en_US.UTF-8')
55 self
.assertEqual(expect
, actual
)
57 def test_guards_against_qstring(self
):
58 """Test that random QString is passed through as-is
60 i18n
.install('en_US.UTF-8')
62 actual
= i18n
.gettext(QtCore
.QString('Random'))
63 self
.assertEqual(expect
, actual
)
66 if __name__
== '__main__':