~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Patch Queue Manager
  • Date: 2016-04-21 04:10:52 UTC
  • mfrom: (6616.1.1 fix-en-user-guide)
  • Revision ID: pqm@pqm.ubuntu.com-20160421041052-clcye7ns1qcl2n7w
(richard-wilbur) Ensure build of English use guide always uses English text
 even when user's locale specifies a different language. (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2010 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
25
25
    urlutils,
26
26
    )
27
27
from bzrlib.tests import EncodingAdapter
28
 
 
29
 
 
30
 
def load_tests(standard_tests, module, loader):
31
 
    return tests.multiply_tests(standard_tests,
32
 
                                EncodingAdapter.encoding_scenarios,
33
 
                                loader.suiteClass())
 
28
from bzrlib.tests.scenarios import load_tests_apply_scenarios
 
29
 
 
30
 
 
31
load_tests = load_tests_apply_scenarios
34
32
 
35
33
 
36
34
class TestNonAscii(tests.TestCaseWithTransport):
37
35
    """Test that bzr handles files/committers/etc which are non-ascii."""
38
36
 
 
37
    scenarios = EncodingAdapter.encoding_scenarios
 
38
 
39
39
    def setUp(self):
40
40
        super(TestNonAscii, self).setUp()
41
41
        self._check_can_encode_paths()
42
42
 
43
43
        self.overrideAttr(osutils, '_cached_user_encoding', self.encoding)
44
44
        email = self.info['committer'] + ' <joe@foo.com>'
45
 
        os.environ['BZR_EMAIL'] = email.encode(osutils.get_user_encoding())
 
45
        self.overrideEnv('BZR_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,
89
89
            normal_thing = unicodedata.normalize('NFD', path)
90
90
            mac_encoded = normal_thing.encode(fs_enc)
91
91
            if mac_encoded != encoded:
92
 
                raise tests.KnownFailure(
 
92
                self.knownFailure(
93
93
                    'Unable to roundtrip path %r on OSX filesystem'
94
94
                    ' using encoding "%s"'
95
95
                    % (path, fs_enc))
161
161
    def test_cat_revision(self):
162
162
        committer = self.info['committer']
163
163
        txt = self.run_bzr_decode('cat-revision -r 1')
164
 
        self.failUnless(committer in txt,
 
164
        self.assertTrue(committer in txt,
165
165
                        'failed to find %r in %r' % (committer, txt))
166
166
 
167
167
        msg = self.info['message']
168
168
        txt = self.run_bzr_decode('cat-revision -r 2')
169
 
        self.failUnless(msg in txt, 'failed to find %r in %r' % (msg, txt))
 
169
        self.assertTrue(msg in txt, 'failed to find %r in %r' % (msg, txt))
170
170
 
171
171
    def test_mkdir(self):
172
172
        txt = self.run_bzr_decode(['mkdir', self.info['directory']])
222
222
 
223
223
        txt = self.run_bzr_decode(['mv', 'a', fname2])
224
224
        self.assertEqual(u'a => %s\n' % fname2, txt)
225
 
        self.failIfExists('a')
226
 
        self.failUnlessExists(fname2)
 
225
        self.assertPathDoesNotExist('a')
 
226
        self.assertPathExists(fname2)
227
227
 
228
228
        # After 'mv' we need to re-open the working tree
229
229
        self.wt = self.wt.bzrdir.open_workingtree()
240
240
        # The rename should still succeed
241
241
        newpath = u'%s/%s' % (dirname, fname2)
242
242
        txt = self.run_bzr_decode(['mv', newpath, 'a'], encoding='ascii')
243
 
        self.failUnlessExists('a')
 
243
        self.assertPathExists('a')
244
244
        self.assertEqual(newpath.encode('ascii', 'replace') + ' => a\n', txt)
245
245
 
246
246
    def test_branch(self):
267
267
 
268
268
        expected = osutils.pathjoin(osutils.getcwd(), dirname1)
269
269
        self.assertEqual(u'Using saved parent location: %s/\n'
270
 
                'No revisions to pull.\n' % (expected,), txt)
 
270
                'No revisions or tags to pull.\n' % (expected,), txt)
271
271
 
272
272
        self.build_tree_contents(
273
273
            [(osutils.pathjoin(dirname1, 'a'), 'and yet more\n')])
386
386
        self.assertEqual(fname+'\n', txt)
387
387
 
388
388
        txt = self.run_bzr_decode('deleted --show-ids')
389
 
        self.failUnless(txt.startswith(fname))
 
389
        self.assertTrue(txt.startswith(fname))
390
390
 
391
391
        # Deleted should fail if cannot decode
392
392
        # Because it is giving the exact paths
421
421
        self.wt.bzrdir.sprout(url)
422
422
 
423
423
        txt = self.run_bzr_decode('root', working_dir=dirname)
424
 
        self.failUnless(txt.endswith(dirname+'\n'))
 
424
        self.assertTrue(txt.endswith(dirname+'\n'))
425
425
 
426
426
        txt = self.run_bzr_decode('root', encoding='ascii', fail=True,
427
427
                                  working_dir=dirname)