~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_locale.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-05-04 12:10:51 UTC
  • mfrom: (5819.1.4 777007-developer-doc)
  • Revision ID: pqm@pqm.ubuntu.com-20110504121051-aovlsmqiivjmc4fc
(jelmer) Small fixes to developer documentation. (Jonathan Riddell)

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
"""Test that bzr handles locales in a reasonable way"""
18
18
 
19
 
import os
20
19
import sys
21
20
 
22
 
from bzrlib.tests import TestCaseWithTransport, TestSkipped
23
 
 
24
 
 
25
 
class TestLocale(TestCaseWithTransport):
 
21
from bzrlib import (
 
22
    tests,
 
23
    )
 
24
 
 
25
 
 
26
class TestLocale(tests.TestCaseWithTransport):
26
27
 
27
28
    def setUp(self):
28
29
        super(TestLocale, self).setUp()
29
30
 
30
31
        if sys.platform in ('win32',):
31
 
            raise TestSkipped('Windows does not respond to the LANG'
32
 
                              ' env variable')
 
32
            raise tests.TestSkipped('Windows does not respond to the LANG'
 
33
                                    ' env variable')
33
34
 
34
35
        tree = self.make_branch_and_tree('tree')
35
36
        self.build_tree(['tree/a'])
41
42
        self.tree = tree
42
43
 
43
44
    def test_log_C(self):
44
 
        out, err = self.run_bzr_subprocess('--no-aliases', '--no-plugins',
45
 
               '-q', 'log', '--log-format=long', 'tree',
46
 
               env_changes={'LANG':'C', 'BZR_PROGRESS_BAR':'none',
47
 
                            'LC_ALL':None, 'LC_CTYPE':None, 'LANGUAGE':None})
 
45
        self.disable_missing_extensions_warning()
 
46
        # C is not necessarily the default locale, so set both LANG and LC_ALL
 
47
        # explicitly because LC_ALL is preferred on (some?) Linux systems but
 
48
        # only LANG is respected on Windows.
 
49
        out, err = self.run_bzr_subprocess(
 
50
            '--no-aliases --no-plugins log -q --log-format=long tree',
 
51
               env_changes={'LANG': 'C', 'BZR_PROGRESS_BAR':'none',
 
52
                            'LC_ALL': 'C', 'LC_CTYPE':None, 'LANGUAGE':None})
48
53
        self.assertEqual('', err)
49
54
        self.assertEqualDiff("""\
50
55
------------------------------------------------------------
57
62
""", out)
58
63
 
59
64
    def test_log_BOGUS(self):
60
 
        out, err = self.run_bzr_subprocess('--no-aliases', '--no-plugins',
61
 
               '-q', 'log', '--log-format=long', 'tree',
 
65
        out, err = self.run_bzr_subprocess(
 
66
            '--no-aliases --no-plugins log -q --log-format=long tree',
62
67
               env_changes={'LANG':'BOGUS', 'BZR_PROGRESS_BAR':'none',
63
68
                            'LC_ALL':None, 'LC_CTYPE':None, 'LANGUAGE':None})
64
 
        # XXX: This depends on the exact formatting of a locale.Error
65
 
        # as the first part of the string. It may be a little tempermental
66
 
        self.assertEqualDiff("""\
67
 
bzr: warning: unsupported locale setting
68
 
  Could not determine what text encoding to use.
69
 
  This error usually means your Python interpreter
70
 
  doesn't support the locale set by $LANG (BOGUS)
71
 
  Continuing with ascii encoding.
72
 
""", err)
 
69
        self.assertStartsWith(err, 'bzr: warning: unsupported locale setting')
73
70
        self.assertEqualDiff("""\
74
71
------------------------------------------------------------
75
72
revno: 1