~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_diff.py

  • Committer: John Arbash Meinel
  • Date: 2006-08-14 16:16:53 UTC
  • mto: (1946.2.6 reduce-knit-churn)
  • mto: This revision was merged to the branch mainline in revision 1919.
  • Revision ID: john@arbash-meinel.com-20060814161653-54cdcdadcd4e9003
Remove bogus entry from BRANCH.TODO

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
import os
18
18
from cStringIO import StringIO
19
19
import errno
20
 
import subprocess
21
20
from tempfile import TemporaryFile
22
21
 
23
22
from bzrlib.diff import internal_diff, external_diff, show_diff_trees
110
109
                                     use_stringio=True)
111
110
        self.check_patch(lines)
112
111
 
113
 
    def test_external_diff_binary_lang_c(self):
114
 
        orig_lang = os.environ.get('LANG')
115
 
        try:
116
 
            os.environ['LANG'] = 'C'
117
 
            lines = external_udiff_lines(['\x00foobar\n'], ['foo\x00bar\n'])
118
 
            self.assertEqual(['Binary files old and new differ\n', '\n'], lines)
119
 
        finally:
120
 
            if orig_lang is None:
121
 
                del os.environ['LANG']
122
 
            else:
123
 
                os.environ['LANG'] = orig_lang
 
112
    def test_external_diff_binary(self):
 
113
        lines = external_udiff_lines(['\x00foobar\n'], ['foo\x00bar\n'])
 
114
        self.assertEqual(['Binary files old and new differ\n', '\n'], lines)
124
115
 
125
116
    def test_no_external_diff(self):
126
117
        """Check that NoDiff is raised when diff is not available"""
191
182
            'internal_diff should return bytestrings')
192
183
 
193
184
 
194
 
class TestDiffFiles(TestCaseInTempDir):
195
 
 
196
 
    def test_external_diff_binary(self):
197
 
        """The output when using external diff should use diff's i18n error"""
198
 
        # Make sure external_diff doesn't fail in the current LANG
199
 
        lines = external_udiff_lines(['\x00foobar\n'], ['foo\x00bar\n'])
200
 
 
201
 
        cmd = ['diff', '-u', 'old', 'new']
202
 
        open('old', 'wb').write('\x00foobar\n')
203
 
        open('new', 'wb').write('foo\x00bar\n')
204
 
        pipe = subprocess.Popen(cmd, stdout=subprocess.PIPE,
205
 
                                     stdin=subprocess.PIPE)
206
 
        out, err = pipe.communicate()
207
 
        # Diff returns '2' on Binary files.
208
 
        self.assertEqual(2, pipe.returncode)
209
 
        # We should output whatever diff tells us, plus a trailing newline
210
 
        self.assertEqual(out.splitlines(True) + ['\n'], lines)
211
 
 
212
 
 
213
185
class TestDiffDates(TestCaseWithTransport):
214
186
 
215
187
    def setUp(self):