1 """Tests for the i18n translation module"""
7 from cola
.i18n
import N_
8 from cola
.compat
import uchr
11 @pytest.fixture(autouse
=True)
13 """Perform cleanup/teardown of the i18n module"""
18 def test_translates_noun():
19 """Test that strings with @@noun are translated"""
21 expect
= uchr(0x30B3) + uchr(0x30DF) + uchr(0x30C3) + uchr(0x30C8)
22 actual
= N_('Commit@@verb')
23 assert expect
== actual
26 def test_translates_verb():
27 """Test that strings with @@verb are translated"""
29 expect
= 'Commit aufnehmen'
30 actual
= N_('Commit@@verb')
31 assert expect
== actual
34 def test_translates_english_noun():
35 """Test that English strings with @@noun are properly handled"""
36 i18n
.install('en_US.UTF-8')
38 actual
= N_('Commit@@noun')
39 assert expect
== actual
42 def test_translates_english_verb():
43 """Test that English strings with @@verb are properly handled"""
44 i18n
.install('en_US.UTF-8')
46 actual
= N_('Commit@@verb')
47 assert expect
== actual
50 def test_translates_random_english():
51 """Test that random English strings are passed through as-is"""
52 i18n
.install('en_US.UTF-8')
55 assert expect
== actual
58 def test_translate_push_pull_french():
62 assert expect
== actual
66 assert expect
== actual
69 def test_get_filename_for_locale():
70 """Ensure that the appropriate .po files are found"""
71 actual
= i18n
.get_filename_for_locale('does_not_exist')
74 actual
= i18n
.get_filename_for_locale('id_ID')
75 assert os
.path
.basename(actual
) == 'id_ID.po'
77 actual
= i18n
.get_filename_for_locale('ja_JP')
78 assert os
.path
.basename(actual
) == 'ja.po'