~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_diff.py

Allow external diff to write to a file without a fileno.

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
    return output.readlines()
34
34
 
35
35
 
36
 
def external_udiff_lines(old, new):
37
 
    output = TemporaryFile()
 
36
def external_udiff_lines(old, new, use_stringio=False):
 
37
    if use_stringio:
 
38
        # StringIO has no fileno, so it tests a different codepath
 
39
        output = StringIO()
 
40
    else:
 
41
        output = TemporaryFile()
38
42
    try:
39
43
        external_diff('old', old, 'new', new, output, diff_opts=['-u'])
40
44
    except errors.NoDiff:
95
99
    def test_external_diff(self):
96
100
        lines = external_udiff_lines(['boo\n'], ['goo\n'])
97
101
        self.check_patch(lines)
 
102
 
 
103
    def test_external_diff_no_fileno(self):
 
104
        # Make sure that we can handle not having a fileno, even
 
105
        # if the diff is large
 
106
        lines = external_udiff_lines(['boo\n']*10000,
 
107
                                     ['goo\n']*10000,
 
108
                                     use_stringio=True)
 
109
        self.check_patch(lines)
98
110
        
99
111
    def test_internal_diff_default(self):
100
112
        # Default internal diff encoding is utf8