1
# Copyright (C) 2006 Canonical Ltd
1
# Copyright (C) 2006, 2011 Canonical Ltd
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
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
17
17
"""Test that bzr handles locales in a reasonable way"""
22
from bzrlib.tests import TestCaseWithTransport, TestSkipped
25
class TestLocale(TestCaseWithTransport):
26
class TestLocale(tests.TestCaseWithTransport):
28
29
super(TestLocale, self).setUp()
30
31
if sys.platform in ('win32',):
31
raise TestSkipped('Windows does not respond to the LANG'
32
raise tests.TestSkipped('Windows does not respond to the LANG'
34
35
tree = self.make_branch_and_tree('tree')
35
36
self.build_tree(['tree/a'])
40
41
timestamp=1156451297.96, timezone=0)
44
def run_log_quiet_long(self, args, env_changes={}):
45
cmd = ['--no-aliases', '--no-plugins', '-Oprogress_bar=none',
46
'log', '-q', '--log-format=long']
48
return self.run_bzr_subprocess(cmd, env_changes=env_changes)
43
50
def test_log_C(self):
44
out, err = self.run_bzr_subprocess(
45
'--no-aliases --no-plugins log -q --log-format=long tree',
46
env_changes={'LANG':'C', 'BZR_PROGRESS_BAR':'none',
47
'LC_ALL':None, 'LC_CTYPE':None, 'LANGUAGE':None})
51
self.disable_missing_extensions_warning()
52
out, err = self.run_log_quiet_long(
54
# C is not necessarily the default locale, so set both LANG and
55
# LC_ALL explicitly because LC_ALL is preferred on (some?) Linux
56
# systems but only LANG is respected on Windows.
57
env_changes={'LANG': 'C', 'LC_ALL': 'C', 'LC_CTYPE':None,
48
59
self.assertEqual('', err)
49
60
self.assertEqualDiff("""\
50
61
------------------------------------------------------------
59
70
def test_log_BOGUS(self):
60
out, err = self.run_bzr_subprocess(
61
'--no-aliases --no-plugins log -q --log-format=long tree',
62
env_changes={'LANG':'BOGUS', 'BZR_PROGRESS_BAR':'none',
63
'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
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.
71
out, err = self.run_log_quiet_long(
73
env_changes={'LANG':'BOGUS', 'LC_ALL':None, 'LC_CTYPE':None,
75
self.assertStartsWith(err, 'bzr: warning: unsupported locale setting')
79
76
self.assertEqualDiff("""\
80
77
------------------------------------------------------------
87
class TestMultibyteCodecs(tests.TestCaseWithTransport):
88
"""Tests for quirks of multibyte encodings and their python codecs"""
90
def test_plugins_mbcs(self):
91
"""Ensure the plugins command works with cjkcodecs, see lp:754082"""
92
self.disable_missing_extensions_warning()
93
out, err = self.run_bzr(["plugins"], encoding="EUC-JP")
94
# The output is tested in bt.test_plugins rather than here
95
self.assertEqual("", err)