~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Andrew Bennetts
  • Date: 2009-08-07 04:17:51 UTC
  • mto: This revision was merged to the branch mainline in revision 4608.
  • Revision ID: andrew.bennetts@canonical.com-20090807041751-0vhb0y0g7k49hr45
Review comments from John.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006, 2011 Canonical Ltd
 
1
# Copyright (C) 2006 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
16
16
 
17
17
"""Test that bzr handles locales in a reasonable way"""
18
18
 
 
19
import os
19
20
import sys
20
21
 
21
 
from bzrlib import (
22
 
    tests,
23
 
    )
24
 
 
25
 
 
26
 
class TestLocale(tests.TestCaseWithTransport):
 
22
from bzrlib.tests import TestCaseWithTransport, TestSkipped
 
23
 
 
24
 
 
25
class TestLocale(TestCaseWithTransport):
27
26
 
28
27
    def setUp(self):
29
28
        super(TestLocale, self).setUp()
30
29
 
31
30
        if sys.platform in ('win32',):
32
 
            raise tests.TestSkipped('Windows does not respond to the LANG'
33
 
                                    ' env variable')
 
31
            raise TestSkipped('Windows does not respond to the LANG'
 
32
                              ' env variable')
34
33
 
35
34
        tree = self.make_branch_and_tree('tree')
36
35
        self.build_tree(['tree/a'])
42
41
        self.tree = tree
43
42
 
44
43
    def test_log_C(self):
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
44
        out, err = self.run_bzr_subprocess(
50
45
            '--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})
 
46
               env_changes={'LANG':'C', 'BZR_PROGRESS_BAR':'none',
 
47
                            'LC_ALL':None, 'LC_CTYPE':None, 'LANGUAGE':None})
53
48
        self.assertEqual('', err)
54
49
        self.assertEqualDiff("""\
55
50
------------------------------------------------------------
66
61
            '--no-aliases --no-plugins log -q --log-format=long tree',
67
62
               env_changes={'LANG':'BOGUS', 'BZR_PROGRESS_BAR':'none',
68
63
                            'LC_ALL':None, 'LC_CTYPE':None, 'LANGUAGE':None})
69
 
        self.assertStartsWith(err, 'bzr: warning: unsupported locale setting')
 
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
  bzr could not set the application locale.
 
69
  Although this should be no problem for bzr itself,
 
70
  it might cause problems with some plugins.
 
71
  To investigate the issue, look at the output
 
72
  of the locale(1p) tool available on POSIX systems.
 
73
bzr: warning: unsupported locale setting
 
74
  Could not determine what text encoding to use.
 
75
  This error usually means your Python interpreter
 
76
  doesn't support the locale set by $LANG (BOGUS)
 
77
  Continuing with ascii encoding.
 
78
""", err)
70
79
        self.assertEqualDiff("""\
71
80
------------------------------------------------------------
72
81
revno: 1
76
85
message:
77
86
  Unicode ? commit
78
87
""", out)
79
 
 
80
 
 
81
 
class TestMultibyteCodecs(tests.TestCaseWithTransport):
82
 
    """Tests for quirks of multibyte encodings and their python codecs"""
83
 
 
84
 
    def test_plugins_mbcs(self):
85
 
        """Ensure the plugins command works with cjkcodecs, see lp:754082"""
86
 
        self.disable_missing_extensions_warning()
87
 
        out, err = self.run_bzr(["plugins"], encoding="EUC-JP")
88
 
        # The output is tested in bt.test_plugins rather than here
89
 
        self.assertEqual("", err)