~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_diff.py

  • Committer: Jonathan Lange
  • Date: 2007-07-09 07:38:03 UTC
  • mto: (2653.1.1 jam-integration)
  • mto: This revision was merged to the branch mainline in revision 2654.
  • Revision ID: jml@mumak.net-20070709073803-i1mxhzhlhs85u32j
Apply jam's comments to test_binary_unicode_filenames. Change the 
'=== added' etc lines to print out the str() of the filename, rather than
the repr(). This means that unicode symbols are displayed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
442
442
                                    '\\+new contents\n')
443
443
 
444
444
    def test_binary_unicode_filenames(self):
445
 
        """Test that contents of files are encoded in UTF-8 when there is a
446
 
        binary file in the diff.
 
445
        """Test that contents of files are *not* encoded in UTF-8 when there
 
446
        is a binary file in the diff.
447
447
        """
448
448
        # See https://bugs.launchpad.net/bugs/110092.
449
449
 
450
450
        # This bug isn't triggered with cStringIO.
451
451
        from StringIO import StringIO
452
452
        tree = self.make_branch_and_tree('tree')
 
453
        alpha, omega = u'\u03b1', u'\u03c9'
 
454
        alpha_utf8, omega_utf8 = alpha.encode('utf8'), omega.encode('utf8')
453
455
        self.build_tree_contents(
454
 
            [('tree/binary', chr(0)),
455
 
             ('tree/elephant', '\xc7a trompe \xc3\xa9norm\xc3\xa9ment.\n')])
456
 
        tree.add(['binary'], ['file-id'])
457
 
        tree.add(['elephant'], ['file-id-2'])
 
456
            [('tree/' + alpha, chr(0)),
 
457
             ('tree/' + omega,
 
458
              ('The %s and the %s\n' % (alpha_utf8, omega_utf8)))])
 
459
        tree.add([alpha], ['file-id'])
 
460
        tree.add([omega], ['file-id-2'])
458
461
        diff_content = StringIO()
459
462
        show_diff_trees(tree.basis_tree(), tree, diff_content)
460
463
        diff = diff_content.getvalue()
461
 
        self.assertContainsRe(diff, "=== added file 'binary'")
 
464
        self.assertContainsRe(diff, r"=== added file '%s'" % alpha_utf8)
462
465
        self.assertContainsRe(
463
 
            diff, "Binary files a/binary.*and b/binary.* differ\n")
464
 
        self.assertContainsRe(diff, "=== added file 'elephant'")
465
 
        self.assertContainsRe(diff, "--- a/elephant")
466
 
        self.assertContainsRe(diff, "\\+\\+\\+ b/elephant")
 
466
            diff, "Binary files a/%s.*and b/%s.* differ\n" % (alpha_utf8, alpha_utf8))
 
467
        self.assertContainsRe(diff, r"=== added file '%s'" % omega_utf8)
 
468
        self.assertContainsRe(diff, r"--- a/%s" % (omega_utf8,))
 
469
        self.assertContainsRe(diff, r"\+\+\+ b/%s" % (omega_utf8,))
467
470
 
468
471
 
469
472
class TestPatienceDiffLib(TestCase):