~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_diff.py

  • Committer: Martin Pool
  • Date: 2010-06-02 04:50:35 UTC
  • mto: This revision was merged to the branch mainline in revision 5279.
  • Revision ID: mbp@canonical.com-20100602045035-sccetnnwizmu01us
Don't say 'Linux' except when specifically talking about the kernel

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
    )
35
35
from bzrlib.symbol_versioning import deprecated_in
36
36
from bzrlib.tests import features
37
 
from bzrlib.tests.blackbox.test_diff import subst_dates
38
37
 
39
38
 
40
39
class _AttribFeature(tests.Feature):
522
521
        self.assertNotContainsRe(d, r"file 'e'")
523
522
        self.assertNotContainsRe(d, r"file 'f'")
524
523
 
 
524
 
525
525
    def test_binary_unicode_filenames(self):
526
526
        """Test that contents of files are *not* encoded in UTF-8 when there
527
527
        is a binary file in the diff.
580
580
        self.assertContainsRe(d, "=== modified file 'mod_%s'"%autf8)
581
581
        self.assertContainsRe(d, "=== removed file 'del_%s'"%autf8)
582
582
 
583
 
    def test_unicode_filename_path_encoding(self):
584
 
        """Test for bug #382699: unicode filenames on Windows should be shown
585
 
        in user encoding.
586
 
        """
587
 
        self.requireFeature(tests.UnicodeFilenameFeature)
588
 
        # The word 'test' in Russian
589
 
        _russian_test = u'\u0422\u0435\u0441\u0442'
590
 
        directory = _russian_test + u'/'
591
 
        test_txt = _russian_test + u'.txt'
592
 
        u1234 = u'\u1234.txt'
593
 
 
594
 
        tree = self.make_branch_and_tree('.')
595
 
        self.build_tree_contents([
596
 
            (test_txt, 'foo\n'),
597
 
            (u1234, 'foo\n'),
598
 
            (directory, None),
599
 
            ])
600
 
        tree.add([test_txt, u1234, directory])
601
 
 
602
 
        sio = StringIO()
603
 
        diff.show_diff_trees(tree.basis_tree(), tree, sio,
604
 
            path_encoding='cp1251')
605
 
 
606
 
        output = subst_dates(sio.getvalue())
607
 
        shouldbe = ('''\
608
 
=== added directory '%(directory)s'
609
 
=== added file '%(test_txt)s'
610
 
--- a/%(test_txt)s\tYYYY-MM-DD HH:MM:SS +ZZZZ
611
 
+++ b/%(test_txt)s\tYYYY-MM-DD HH:MM:SS +ZZZZ
612
 
@@ -0,0 +1,1 @@
613
 
+foo
614
 
 
615
 
=== added file '?.txt'
616
 
--- a/?.txt\tYYYY-MM-DD HH:MM:SS +ZZZZ
617
 
+++ b/?.txt\tYYYY-MM-DD HH:MM:SS +ZZZZ
618
 
@@ -0,0 +1,1 @@
619
 
+foo
620
 
 
621
 
''' % {'directory': _russian_test.encode('cp1251'),
622
 
       'test_txt': test_txt.encode('cp1251'),
623
 
      })
624
 
        self.assertEqualDiff(output, shouldbe)
625
 
 
626
583
 
627
584
class DiffWasIs(diff.DiffPath):
628
585