1
# Copyright (C) 2006 by Canonical Ltd
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
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
17
"""Test that bzr handles locales in a reasonable way"""
22
from bzrlib.tests import TestCaseWithTransport
25
class TestLocale(TestCaseWithTransport):
28
super(TestLocale, self).setUp()
30
if sys.platform in ('win32',):
31
raise TestSkipped('Windows does not respond to the LANG'
33
orig_progress = os.environ.get('BZR_PROGRESS_BAR')
34
orig_lang = os.environ.get('LANG')
38
del os.environ['LANG']
40
os.environ['LANG'] = orig_lang
41
if orig_progress is None:
42
del os.environ['BZR_PROGRESS_BAR']
44
os.environ['BZR_PROGRESS_BAR'] = orig_progress
46
self.addCleanup(restore)
47
# Don't confuse things with progress bars
48
os.environ['BZR_PROGRESS_BAR'] = 'none'
50
tree = self.make_branch_and_tree('tree')
51
self.build_tree(['tree/a'])
53
tree.commit(u'Unicode \xb5 commit', rev_id='r1',
54
committer=u'\u062c\u0648\u062c\u0648'
55
u' Meinel <juju@info.com>',
56
timestamp=1156451297.96, timezone=0)
60
os.environ['LANG'] = 'C'
61
out, err = self.run_bzr_subprocess('--no-aliases', '--no-plugins',
62
'-q', 'log', '--log-format=long',
64
self.assertEqual('', err)
65
self.assertEqualDiff("""\
66
------------------------------------------------------------
68
committer: ???? Meinel <juju@info.com>
70
timestamp: Thu 2006-08-24 20:28:17 +0000
75
def test_log_BOGUS(self):
76
os.environ['LANG'] = 'BOGUS'
77
out, err = self.run_bzr_subprocess('--no-aliases', '--no-plugins',
78
'-q', 'log', '--log-format=long',
80
# XXX: This depends on the exact formatting of a locale.Error
81
# as the first part of the string. It may be a little tempermental
82
self.assertEqualDiff("""\
83
bzr: warning: unsupported locale setting
84
Could not what text encoding to use.
85
This error usually means your Python interpreter
86
doesn't support the locale set by $LANG (BOGUS)
87
Continuing with ascii encoding.
89
self.assertEqualDiff("""\
90
------------------------------------------------------------
92
committer: ???? Meinel <juju@info.com>
94
timestamp: Thu 2006-08-24 20:28:17 +0000