/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

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

  • Committer: Jelmer Vernooij
  • Date: 2018-07-08 10:56:06 UTC
  • mto: This revision was merged to the branch mainline in revision 7030.
  • Revision ID: jelmer@jelmer.uk-20180708105606-d53hkks89qq88twu
Use separate .as_bytes method rather than __bytes__.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006 Canonical Ltd
 
1
# Copyright (C) 2006, 2011 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
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
 
"""Test that bzr handles locales in a reasonable way"""
 
17
"""Test that brz handles locales in a reasonable way"""
18
18
 
19
 
import os
20
19
import sys
21
20
 
22
 
from bzrlib import (
 
21
from breezy import (
23
22
    tests,
24
23
    )
25
24
 
36
35
        tree = self.make_branch_and_tree('tree')
37
36
        self.build_tree(['tree/a'])
38
37
        tree.add('a')
39
 
        tree.commit(u'Unicode \xb5 commit', rev_id='r1',
 
38
        tree.commit(u'Unicode \xb5 commit', rev_id=b'r1',
40
39
                    committer=u'\u062c\u0648\u062c\u0648'
41
40
                              u' Meinel <juju@info.com>',
42
41
                    timestamp=1156451297.96, timezone=0)
43
42
        self.tree = tree
44
43
 
 
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']
 
47
        cmd.extend(args)
 
48
        return self.run_bzr_subprocess(cmd, env_changes=env_changes)
 
49
 
45
50
    def test_log_C(self):
46
51
        self.disable_missing_extensions_warning()
47
 
        out, err = self.run_bzr_subprocess(
48
 
            '--no-aliases --no-plugins log -q --log-format=long tree',
49
 
               env_changes={'LANG':'C', 'BZR_PROGRESS_BAR':'none',
50
 
                            'LC_ALL':None, 'LC_CTYPE':None, 'LANGUAGE':None})
51
 
        self.assertEqual('', err)
52
 
        self.assertEqualDiff("""\
 
52
        out, err = self.run_log_quiet_long(
 
53
            ['tree'],
 
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,
 
58
                         'LANGUAGE':None})
 
59
        self.assertEqual(b'', err)
 
60
        self.assertEqualDiff(b"""\
53
61
------------------------------------------------------------
54
62
revno: 1
55
63
committer: ???? Meinel <juju@info.com>
60
68
""", out)
61
69
 
62
70
    def test_log_BOGUS(self):
63
 
        out, err = self.run_bzr_subprocess(
64
 
            '--no-aliases --no-plugins log -q --log-format=long tree',
65
 
               env_changes={'LANG':'BOGUS', 'BZR_PROGRESS_BAR':'none',
66
 
                            'LC_ALL':None, 'LC_CTYPE':None, 'LANGUAGE':None})
67
 
        self.assertStartsWith(err, 'bzr: warning: unsupported locale setting')
68
 
        self.assertEqualDiff("""\
 
71
        out, err = self.run_log_quiet_long(
 
72
            ['tree'],
 
73
            env_changes={'LANG':'BOGUS', 'LC_ALL':None, 'LC_CTYPE':None,
 
74
                         'LANGUAGE':None})
 
75
        self.assertStartsWith(err, b'brz: warning: unsupported locale setting')
 
76
        self.assertEqualDiff(b"""\
69
77
------------------------------------------------------------
70
78
revno: 1
71
79
committer: ???? Meinel <juju@info.com>
74
82
message:
75
83
  Unicode ? commit
76
84
""", out)
 
85
 
 
86
 
 
87
class TestMultibyteCodecs(tests.TestCaseWithTransport):
 
88
    """Tests for quirks of multibyte encodings and their python codecs"""
 
89
 
 
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)