~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_i18n.py

  • Committer: Patch Queue Manager
  • Date: 2011-09-08 11:01:15 UTC
  • mfrom: (6123.1.16 gpg-typo)
  • Revision ID: pqm@cupuasso-20110908110115-gbb9benwkdksvzk5
(jelmer) Fix a typo (invalid format identifier) in an error message in
 bzrlib.gpg. (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""Tests for bzrlib.i18n"""
18
18
 
19
 
from bzrlib import (
20
 
    i18n,
21
 
    tests,
22
 
    errors,
23
 
    workingtree,
24
 
    )
 
19
from bzrlib import (i18n, 
 
20
                    tests, 
 
21
                    errors, 
 
22
                    workingtree,
 
23
                    )
25
24
 
26
25
 
27
26
class ZzzTranslations(object):
98
97
 
99
98
class TestInstall(tests.TestCase):
100
99
 
101
 
    def setUp(self):
102
 
        super(TestInstall, self).setUp()
103
 
        # Restore a proper env to test translation installation
104
 
        self.overrideAttr(i18n, '_translations', None)
105
 
 
106
100
    def test_custom_languages(self):
 
101
        self.addCleanup(i18n.install)
107
102
        i18n.install('nl:fy')
108
 
        # Whether we found a valid tranlsation or not doesn't matter, we got
109
 
        # one and _translations is not None anymore.
110
 
        self.assertIsInstance(i18n._translations,
111
 
                              i18n._gettext.NullTranslations)
112
103
 
113
104
    def test_no_env_variables(self):
 
105
        self.addCleanup(i18n.install)
114
106
        self.overrideEnv('LANGUAGE', None)
115
107
        self.overrideEnv('LC_ALL', None)
116
108
        self.overrideEnv('LC_MESSAGES', None)
117
109
        self.overrideEnv('LANG', None)
118
110
        i18n.install()
119
 
        # Whether we found a valid tranlsation or not doesn't matter, we got
120
 
        # one and _translations is not None anymore.
121
 
        self.assertIsInstance(i18n._translations,
122
 
                              i18n._gettext.NullTranslations)
123
 
 
124
 
    def test_disable_i18n(self):
125
 
        i18n.disable_i18n()
126
 
        i18n.install()
127
 
        # It's disabled, you can't install anything and we fallback to null
128
 
        self.assertIsInstance(i18n._translations,
129
 
                              i18n._gettext.NullTranslations)
130
 
 
131
111
 
132
112
class TestTranslate(tests.TestCaseWithTransport):
133
113
 
139
119
        """do errors get translated?"""
140
120
        err = None
141
121
        tree = self.make_branch_and_tree('.')
 
122
        self.overrideAttr(i18n, '_translations', ZzzTranslations())
142
123
        try:
143
124
            workingtree.WorkingTree.open('./foo')
144
125
        except errors.NotBranchError,e:
149
130
    def test_topic_help_translation(self):
150
131
        """does topic help get translated?"""
151
132
        from bzrlib import help
 
133
        i18n.install()
 
134
        self.overrideAttr(i18n, '_translations', ZzzTranslations())
152
135
        from StringIO import StringIO
153
136
        out = StringIO()
154
137
        help.help("authentication", out)
155
138
        self.assertContainsRe(out.getvalue(), "zz\xe5{{Authentication Settings")
156
 
 
157
 
 
158
 
class LoadPluginTranslations(tests.TestCase):
159
 
 
160
 
    def test_does_not_exist(self):
161
 
        translation = i18n.load_plugin_translations("doesnotexist")
162
 
        self.assertEquals("foo", translation.gettext("foo"))