~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_diff.py

(mbp) merge bzr.dev to 0.8, prepare for release

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from cStringIO import StringIO
 
2
 
 
3
from bzrlib.diff import internal_diff
 
4
from bzrlib.errors import BinaryFile
1
5
from bzrlib.tests import TestCase
2
 
from bzrlib.diff import internal_diff
3
 
from cStringIO import StringIO
4
 
def udiff_lines(old, new):
 
6
 
 
7
 
 
8
def udiff_lines(old, new, allow_binary=False):
5
9
    output = StringIO()
6
 
    internal_diff('old', old, 'new', new, output)
 
10
    internal_diff('old', old, 'new', new, output, allow_binary)
7
11
    output.seek(0, 0)
8
12
    return output.readlines()
9
13
 
47
51
        self.assert_('@@' in lines[2][2:])
48
52
            ## "Unterminated hunk header for patch:\n%s" % "".join(lines)
49
53
 
 
54
    def test_binary_lines(self):
 
55
        self.assertRaises(BinaryFile, udiff_lines, [1023 * 'a' + '\x00'], [])
 
56
        self.assertRaises(BinaryFile, udiff_lines, [], [1023 * 'a' + '\x00'])
 
57
        udiff_lines([1023 * 'a' + '\x00'], [], allow_binary=True)
 
58
        udiff_lines([], [1023 * 'a' + '\x00'], allow_binary=True)