/breezy/unstable

To get this branch, use:
bzr branch https://code.breezy-vcs.org/breezy/unstable

« back to all changes in this revision

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

  • Committer: Jelmer Vernooij
  • Date: 2017-05-24 01:39:33 UTC
  • mfrom: (3815.3776.6)
  • Revision ID: jelmer@jelmer.uk-20170524013933-ir4y4tqtrsiz2ka2
New upstream snapshot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
 
"""Black-box tests for bzr handling non-ascii characters."""
 
17
"""Black-box tests for brz handling non-ascii characters."""
18
18
 
19
19
import os
20
20
import sys
21
21
 
22
 
from bzrlib import (
 
22
from breezy import (
23
23
    osutils,
24
24
    tests,
25
25
    urlutils,
26
26
    )
27
 
from bzrlib.tests import EncodingAdapter
28
 
from bzrlib.tests.scenarios import load_tests_apply_scenarios
 
27
from breezy.tests import EncodingAdapter
 
28
from breezy.tests.scenarios import load_tests_apply_scenarios
29
29
 
30
30
 
31
31
load_tests = load_tests_apply_scenarios
32
32
 
33
33
 
34
34
class TestNonAscii(tests.TestCaseWithTransport):
35
 
    """Test that bzr handles files/committers/etc which are non-ascii."""
 
35
    """Test that brz handles files/committers/etc which are non-ascii."""
36
36
 
37
37
    scenarios = EncodingAdapter.encoding_scenarios
38
38
 
42
42
 
43
43
        self.overrideAttr(osutils, '_cached_user_encoding', self.encoding)
44
44
        email = self.info['committer'] + ' <joe@foo.com>'
45
 
        self.overrideEnv('BZR_EMAIL', email.encode(osutils.get_user_encoding()))
 
45
        self.overrideEnv('BRZ_EMAIL', email.encode(osutils.get_user_encoding()))
46
46
        self.create_base()
47
47
 
48
48
    def run_bzr_decode(self, args, encoding=None, fail=False, retcode=None,
49
49
                       working_dir=None):
50
 
        """Run bzr and decode the output into a particular encoding.
 
50
        """Run brz and decode the output into a particular encoding.
51
51
 
52
52
        Returns a string containing the stdout output from bzr.
53
53
 
57
57
        if encoding is None:
58
58
            encoding = osutils.get_user_encoding()
59
59
        try:
60
 
            out = self.run_bzr(args,
61
 
                               output_encoding=encoding, encoding=encoding,
 
60
            out = self.run_bzr(args, encoding=encoding,
62
61
                               retcode=retcode, working_dir=working_dir)[0]
63
62
            return out.decode(encoding)
64
 
        except UnicodeError, e:
 
63
        except UnicodeError as e:
65
64
            if not fail:
66
65
                raise
67
66
        else:
149
148
        self.assertEqual(expected, txt)
150
149
 
151
150
    def test_cat(self):
152
 
        # bzr cat shouldn't change the contents
153
 
        # using run_bzr since that doesn't decode
 
151
        # brz cat shouldn't change the contents
 
152
        # using run_brz since that doesn't decode
154
153
        txt = self.run_bzr('cat b')[0]
155
154
        self.assertEqual('non-ascii \xFF\xFF\xFC\xFB\x00 in b\n', txt)
156
155
 
477
476
        fname = self.info['filename'] + '2'
478
477
        self.build_tree_contents([(fname, 'unknown\n')])
479
478
 
480
 
        # TODO: jam 20060112 bzr unknowns is the only one which
 
479
        # TODO: jam 20060112 brz unknowns is the only one which
481
480
        #       quotes paths do we really want it to?
482
481
        #       awilkins 20080521 added and modified do it now as well
483
482
        txt = self.run_bzr_decode('unknowns')