1 # -*- encoding: utf-8 -*-
3 from PyQt4
import QtCore
6 from cola
import version
9 if version
.check('pyqt_qrunnable', QtCore
.PYQT_VERSION_STR
):
10 BaseTestCase
= unittest
.TestCase
15 class ColaApplicationTestCase(BaseTestCase
):
16 """Test cases for the ColaApplication class"""
18 def test_translates_noun(self
):
19 """Test that strings with @@noun are translated
21 app
= cola
.app
.ColaApplication([], locale
='ja_JP', gui
=False)
22 expected
= (unichr(0x30b3) + unichr(0x30df) +
23 unichr(0x30c3) + unichr(0x30c8))
24 self
.assertEqual(app
.translate('??', 'Commit@@noun'), expected
)
26 def test_translates_verb(self
):
27 """Test that strings with @@verb are translated
29 app
= cola
.app
.ColaApplication([], locale
='de_DE', gui
=False)
30 self
.assertEqual(app
.translate('??', 'Commit@@verb'), 'Eintragen')
32 def test_translates_english_noun(self
):
33 """Test that English strings with @@noun are properly handled
35 app
= cola
.app
.ColaApplication([], locale
='en_US.UTF-8', gui
=False)
36 self
.assertEqual(app
.translate('??', 'Commit@@noun'), 'Commit')
38 def test_translates_english_verb(self
):
39 """Test that English strings with @@verb are properly handled
41 app
= cola
.app
.ColaApplication([], locale
='en_US.UTF-8', gui
=False)
42 self
.assertEqual(app
.translate('??', 'Commit@@verb'), 'Commit')
44 def test_translates_random_english(self
):
45 """Test that random English strings are passed through as-is
47 app
= cola
.app
.ColaApplication([], locale
='en_US.UTF-8', gui
=False)
48 self
.assertEqual(app
.translate('??', 'Random'), 'Random')
50 def test_guards_against_qstring(self
):
51 """Test that random English strings are passed through as-is
53 app
= cola
.app
.ColaApplication([], locale
='en_US.UTF-8', gui
=False)
54 qstr
= QtCore
.QString('Random')
55 self
.assertEqual(app
.translate('??', qstr
), 'Random')
58 if __name__
== '__main__':