doc: use rst code blocks
[git-cola.git] / test / i18n_test.py
bloba95a439469a6a3aedfee55230dedc7122c6509a7
1 """Tests for the i18n translation module"""
2 from __future__ import absolute_import, division, print_function, unicode_literals
4 import pytest
6 from cola import i18n
7 from cola.i18n import N_
8 from cola.compat import uchr
11 @pytest.fixture(autouse=True)
12 def i18n_context():
13 """Perform cleanup/teardown of the i18n module"""
14 yield
15 i18n.uninstall()
18 def test_translates_noun():
19 """Test that strings with @@noun are translated"""
20 i18n.install('ja_JP')
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"""
28 i18n.install('de_DE')
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')
37 expect = 'Commit'
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')
45 expect = 'Commit'
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')
53 expect = 'Random'
54 actual = N_('Random')
55 assert expect == actual
58 def test_translate_push_pull_french():
59 i18n.install('fr_FR')
60 expect = 'Tirer'
61 actual = N_('Pull')
62 assert expect == actual
64 expect = 'Pousser'
65 actual = N_('Push')
66 assert expect == actual