/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_diff.py

  • Committer: Martin Pool
  • Date: 2006-06-10 23:16:19 UTC
  • mfrom: (1759 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1761.
  • Revision ID: mbp@sourcefrog.net-20060610231619-05b997deeb005d02
[merge] bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2005, 2006 Canonical Development Ltd
 
2
#
 
3
# This program is free software; you can redistribute it and/or modify
 
4
# it under the terms of the GNU General Public License as published by
 
5
# the Free Software Foundation; either version 2 of the License, or
 
6
# (at your option) any later version.
 
7
#
 
8
# This program is distributed in the hope that it will be useful,
 
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
# GNU General Public License for more details.
 
12
 
 
13
# You should have received a copy of the GNU General Public License
 
14
# along with this program; if not, write to the Free Software
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
16
 
 
17
import os
1
18
from cStringIO import StringIO
2
19
 
3
 
from bzrlib.diff import internal_diff
 
20
from bzrlib.diff import internal_diff, show_diff_trees
4
21
from bzrlib.errors import BinaryFile
5
 
from bzrlib.patiencediff import (recurse_matches, SequenceMatcher, unique_lcs,
6
 
                                 unified_diff, unified_diff_files)
 
22
import bzrlib.patiencediff
 
23
from bzrlib.tests import TestCase, TestCaseWithTransport, TestCaseInTempDir
7
24
from bzrlib.tests import TestCase, TestCaseInTempDir
8
25
 
9
26
 
61
78
        udiff_lines([1023 * 'a' + '\x00'], [], allow_binary=True)
62
79
        udiff_lines([], [1023 * 'a' + '\x00'], allow_binary=True)
63
80
 
64
 
 
65
 
class TestCDVDiffLib(TestCase):
 
81
    def test_internal_diff_default(self):
 
82
        # Default internal diff encoding is utf8
 
83
        output = StringIO()
 
84
        internal_diff(u'old_\xb5', ['old_text\n'],
 
85
                    u'new_\xe5', ['new_text\n'], output)
 
86
        lines = output.getvalue().splitlines(True)
 
87
        self.check_patch(lines)
 
88
        self.assertEquals(['--- old_\xc2\xb5\n',
 
89
                           '+++ new_\xc3\xa5\n',
 
90
                           '@@ -1,1 +1,1 @@\n',
 
91
                           '-old_text\n',
 
92
                           '+new_text\n',
 
93
                           '\n',
 
94
                          ]
 
95
                          , lines)
 
96
 
 
97
    def test_internal_diff_utf8(self):
 
98
        output = StringIO()
 
99
        internal_diff(u'old_\xb5', ['old_text\n'],
 
100
                    u'new_\xe5', ['new_text\n'], output,
 
101
                    path_encoding='utf8')
 
102
        lines = output.getvalue().splitlines(True)
 
103
        self.check_patch(lines)
 
104
        self.assertEquals(['--- old_\xc2\xb5\n',
 
105
                           '+++ new_\xc3\xa5\n',
 
106
                           '@@ -1,1 +1,1 @@\n',
 
107
                           '-old_text\n',
 
108
                           '+new_text\n',
 
109
                           '\n',
 
110
                          ]
 
111
                          , lines)
 
112
 
 
113
    def test_internal_diff_iso_8859_1(self):
 
114
        output = StringIO()
 
115
        internal_diff(u'old_\xb5', ['old_text\n'],
 
116
                    u'new_\xe5', ['new_text\n'], output,
 
117
                    path_encoding='iso-8859-1')
 
118
        lines = output.getvalue().splitlines(True)
 
119
        self.check_patch(lines)
 
120
        self.assertEquals(['--- old_\xb5\n',
 
121
                           '+++ new_\xe5\n',
 
122
                           '@@ -1,1 +1,1 @@\n',
 
123
                           '-old_text\n',
 
124
                           '+new_text\n',
 
125
                           '\n',
 
126
                          ]
 
127
                          , lines)
 
128
 
 
129
    def test_internal_diff_returns_bytes(self):
 
130
        import StringIO
 
131
        output = StringIO.StringIO()
 
132
        internal_diff(u'old_\xb5', ['old_text\n'],
 
133
                    u'new_\xe5', ['new_text\n'], output)
 
134
        self.failUnless(isinstance(output.getvalue(), str),
 
135
            'internal_diff should return bytestrings')
 
136
 
 
137
 
 
138
class TestDiffDates(TestCaseWithTransport):
 
139
 
 
140
    def setUp(self):
 
141
        super(TestDiffDates, self).setUp()
 
142
        self.wt = self.make_branch_and_tree('.')
 
143
        self.b = self.wt.branch
 
144
        self.build_tree_contents([
 
145
            ('file1', 'file1 contents at rev 1\n'),
 
146
            ('file2', 'file2 contents at rev 1\n')
 
147
            ])
 
148
        self.wt.add(['file1', 'file2'])
 
149
        self.wt.commit(
 
150
            message='Revision 1',
 
151
            timestamp=1143849600, # 2006-04-01 00:00:00 UTC
 
152
            timezone=0,
 
153
            rev_id='rev-1')
 
154
        self.build_tree_contents([('file1', 'file1 contents at rev 2\n')])
 
155
        self.wt.commit(
 
156
            message='Revision 2',
 
157
            timestamp=1143936000, # 2006-04-02 00:00:00 UTC
 
158
            timezone=28800,
 
159
            rev_id='rev-2')
 
160
        self.build_tree_contents([('file2', 'file2 contents at rev 3\n')])
 
161
        self.wt.commit(
 
162
            message='Revision 3',
 
163
            timestamp=1144022400, # 2006-04-03 00:00:00 UTC
 
164
            timezone=-3600,
 
165
            rev_id='rev-3')
 
166
        self.wt.remove(['file2'])
 
167
        self.wt.commit(
 
168
            message='Revision 4',
 
169
            timestamp=1144108800, # 2006-04-04 00:00:00 UTC
 
170
            timezone=0,
 
171
            rev_id='rev-4')
 
172
        self.build_tree_contents([
 
173
            ('file1', 'file1 contents in working tree\n')
 
174
            ])
 
175
        # set the date stamps for files in the working tree to known values
 
176
        os.utime('file1', (1144195200, 1144195200)) # 2006-04-05 00:00:00 UTC
 
177
 
 
178
    def get_diff(self, tree1, tree2):
 
179
        output = StringIO()
 
180
        show_diff_trees(tree1, tree2, output,
 
181
                        old_label='old/', new_label='new/')
 
182
        return output.getvalue()
 
183
 
 
184
    def test_diff_rev_tree_working_tree(self):
 
185
        output = self.get_diff(self.wt.basis_tree(), self.wt)
 
186
        # note that the date for old/file1 is from rev 2 rather than from
 
187
        # the basis revision (rev 4)
 
188
        self.assertEqualDiff(output, '''\
 
189
=== modified file 'file1'
 
190
--- old/file1\t2006-04-02 00:00:00 +0000
 
191
+++ new/file1\t2006-04-05 00:00:00 +0000
 
192
@@ -1,1 +1,1 @@
 
193
-file1 contents at rev 2
 
194
+file1 contents in working tree
 
195
 
 
196
''')
 
197
 
 
198
    def test_diff_rev_tree_rev_tree(self):
 
199
        tree1 = self.b.repository.revision_tree('rev-2')
 
200
        tree2 = self.b.repository.revision_tree('rev-3')
 
201
        output = self.get_diff(tree1, tree2)
 
202
        self.assertEqualDiff(output, '''\
 
203
=== modified file 'file2'
 
204
--- old/file2\t2006-04-01 00:00:00 +0000
 
205
+++ new/file2\t2006-04-03 00:00:00 +0000
 
206
@@ -1,1 +1,1 @@
 
207
-file2 contents at rev 1
 
208
+file2 contents at rev 3
 
209
 
 
210
''')
 
211
        
 
212
    def test_diff_add_files(self):
 
213
        tree1 = self.b.repository.revision_tree(None)
 
214
        tree2 = self.b.repository.revision_tree('rev-1')
 
215
        output = self.get_diff(tree1, tree2)
 
216
        # the files have the epoch time stamp for the tree in which
 
217
        # they don't exist.
 
218
        self.assertEqualDiff(output, '''\
 
219
=== added file 'file1'
 
220
--- old/file1\t1970-01-01 00:00:00 +0000
 
221
+++ new/file1\t2006-04-01 00:00:00 +0000
 
222
@@ -0,0 +1,1 @@
 
223
+file1 contents at rev 1
 
224
 
 
225
=== added file 'file2'
 
226
--- old/file2\t1970-01-01 00:00:00 +0000
 
227
+++ new/file2\t2006-04-01 00:00:00 +0000
 
228
@@ -0,0 +1,1 @@
 
229
+file2 contents at rev 1
 
230
 
 
231
''')
 
232
 
 
233
    def test_diff_remove_files(self):
 
234
        tree1 = self.b.repository.revision_tree('rev-3')
 
235
        tree2 = self.b.repository.revision_tree('rev-4')
 
236
        output = self.get_diff(tree1, tree2)
 
237
        # the file has the epoch time stamp for the tree in which
 
238
        # it doesn't exist.
 
239
        self.assertEqualDiff(output, '''\
 
240
=== removed file 'file2'
 
241
--- old/file2\t2006-04-03 00:00:00 +0000
 
242
+++ new/file2\t1970-01-01 00:00:00 +0000
 
243
@@ -1,1 +0,0 @@
 
244
-file2 contents at rev 3
 
245
 
 
246
''')
 
247
 
 
248
 
 
249
class TestPatienceDiffLib(TestCase):
66
250
 
67
251
    def test_unique_lcs(self):
 
252
        unique_lcs = bzrlib.patiencediff.unique_lcs
68
253
        self.assertEquals(unique_lcs('', ''), [])
69
254
        self.assertEquals(unique_lcs('a', 'a'), [(0,0)])
70
255
        self.assertEquals(unique_lcs('a', 'b'), [])
78
263
    def test_recurse_matches(self):
79
264
        def test_one(a, b, matches):
80
265
            test_matches = []
81
 
            recurse_matches(a, b, len(a), len(b), test_matches, 10)
 
266
            bzrlib.patiencediff.recurse_matches(a, b, 0, 0, len(a), len(b),
 
267
                test_matches, 10)
82
268
            self.assertEquals(test_matches, matches)
83
269
 
84
 
        test_one(['a', None, 'b', None, 'c'], ['a', 'a', 'b', 'c', 'c'],
 
270
        test_one(['a', '', 'b', '', 'c'], ['a', 'a', 'b', 'c', 'c'],
85
271
                 [(0, 0), (2, 2), (4, 4)])
86
272
        test_one(['a', 'c', 'b', 'a', 'c'], ['a', 'b', 'c'],
87
273
                 [(0, 0), (2, 1), (4, 2)])
97
283
        test_one('aBccDe', 'abccde', [(0,0), (5,5)])
98
284
 
99
285
    def test_matching_blocks(self):
100
 
        def chk_blocks(a, b, matching):
 
286
        def chk_blocks(a, b, expected_blocks):
101
287
            # difflib always adds a signature of the total
102
288
            # length, with no matching entries at the end
103
 
            s = SequenceMatcher(None, a, b)
 
289
            s = bzrlib.patiencediff.PatienceSequenceMatcher(None, a, b)
104
290
            blocks = s.get_matching_blocks()
105
 
            x = blocks.pop()
106
 
            self.assertEquals(x, (len(a), len(b), 0))
107
 
            self.assertEquals(matching, blocks)
 
291
            self.assertEquals((len(a), len(b), 0), blocks[-1])
 
292
            self.assertEquals(expected_blocks, blocks[:-1])
108
293
 
109
294
        # Some basic matching tests
110
295
        chk_blocks('', '', [])
133
318
                    'how are you today?\n'],
134
319
                [(0, 0, 1), (2, 1, 1)])
135
320
 
136
 
        chk_blocks('aBccDe', 'abccde', [(0,0,1), (2,2,2), (5,5,1)])
137
 
 
138
 
        chk_blocks('aBcdEcdFg', 'abcdecdfg', [(0,0,1), (2,2,2),
139
 
                                              (5,5,2), (8,8,1)])
140
 
 
141
 
        chk_blocks('abbabbXd', 'cabbabxd', [(0,1,5), (7,7,1)])
142
 
        chk_blocks('abbabbbb', 'cabbabbc', [(0,1,6)])
143
 
        chk_blocks('bbbbbbbb', 'cbbbbbbc', [(0,1,6)])
 
321
        # non unique lines surrounded by non-matching lines
 
322
        # won't be found
 
323
        chk_blocks('aBccDe', 'abccde', [(0,0,1), (5,5,1)])
 
324
 
 
325
        # But they only need to be locally unique
 
326
        chk_blocks('aBcDec', 'abcdec', [(0,0,1), (2,2,1), (4,4,2)])
 
327
 
 
328
        # non unique blocks won't be matched
 
329
        chk_blocks('aBcdEcdFg', 'abcdecdfg', [(0,0,1), (8,8,1)])
 
330
 
 
331
        # but locally unique ones will
 
332
        chk_blocks('aBcdEeXcdFg', 'abcdecdfg', [(0,0,1), (2,2,2),
 
333
                                              (5,4,1), (7,5,2), (10,8,1)])
 
334
 
 
335
        chk_blocks('abbabbXd', 'cabbabxd', [(7,7,1)])
 
336
        chk_blocks('abbabbbb', 'cabbabbc', [])
 
337
        chk_blocks('bbbbbbbb', 'cbbbbbbc', [])
144
338
 
145
339
    def test_opcodes(self):
146
 
        def chk_ops(a, b, codes):
147
 
            s = SequenceMatcher(None, a, b)
148
 
            self.assertEquals(codes, s.get_opcodes())
 
340
        def chk_ops(a, b, expected_codes):
 
341
            s = bzrlib.patiencediff.PatienceSequenceMatcher(None, a, b)
 
342
            self.assertEquals(expected_codes, s.get_opcodes())
149
343
 
150
344
        chk_ops('', '', [])
151
345
        chk_ops([], [], [])
185
379
                , 'how are you today?\n'],
186
380
                [('equal',  0,1, 0,1),
187
381
                 ('delete', 1,2, 1,1),
188
 
                 ('equal',  2,3, 1,2)
 
382
                 ('equal',  2,3, 1,2),
189
383
                ])
190
384
        chk_ops('aBccDe', 'abccde', 
191
385
                [('equal',   0,1, 0,1),
 
386
                 ('replace', 1,5, 1,5),
 
387
                 ('equal',   5,6, 5,6),
 
388
                ])
 
389
        chk_ops('aBcDec', 'abcdec', 
 
390
                [('equal',   0,1, 0,1),
192
391
                 ('replace', 1,2, 1,2),
193
 
                 ('equal',   2,4, 2,4),
194
 
                 ('replace', 4,5, 4,5),
195
 
                 ('equal',   5,6, 5,6)
 
392
                 ('equal',   2,3, 2,3),
 
393
                 ('replace', 3,4, 3,4),
 
394
                 ('equal',   4,6, 4,6),
196
395
                ])
197
396
        chk_ops('aBcdEcdFg', 'abcdecdfg', 
198
397
                [('equal',   0,1, 0,1),
199
 
                 ('replace', 1,2, 1,2),
200
 
                 ('equal',   2,4, 2,4),
201
 
                 ('replace', 4,5, 4,5),
202
 
                 ('equal',   5,7, 5,7),
203
 
                 ('replace', 7,8, 7,8),
 
398
                 ('replace', 1,8, 1,8),
204
399
                 ('equal',   8,9, 8,9)
205
400
                ])
 
401
        chk_ops('aBcdEeXcdFg', 'abcdecdfg', 
 
402
                [('equal',   0,1, 0,1),
 
403
                 ('replace', 1,2, 1,2),
 
404
                 ('equal',   2,4, 2,4),
 
405
                 ('delete', 4,5, 4,4),
 
406
                 ('equal',   5,6, 4,5),
 
407
                 ('delete', 6,7, 5,5),
 
408
                 ('equal',   7,9, 5,7),
 
409
                 ('replace', 9,10, 7,8),
 
410
                 ('equal',   10,11, 8,9)
 
411
                ])
206
412
 
207
413
    def test_multiple_ranges(self):
208
414
        # There was an earlier bug where we used a bad set of ranges,
209
415
        # this triggers that specific bug, to make sure it doesn't regress
210
 
        def chk_blocks(a, b, matching):
 
416
        def chk_blocks(a, b, expected_blocks):
211
417
            # difflib always adds a signature of the total
212
418
            # length, with no matching entries at the end
213
 
            s = SequenceMatcher(None, a, b)
 
419
            s = bzrlib.patiencediff.PatienceSequenceMatcher(None, a, b)
214
420
            blocks = s.get_matching_blocks()
215
421
            x = blocks.pop()
216
422
            self.assertEquals(x, (len(a), len(b), 0))
217
 
            self.assertEquals(matching, blocks)
 
423
            self.assertEquals(expected_blocks, blocks)
218
424
 
219
425
        chk_blocks('abcdefghijklmnop'
220
426
                 , 'abcXghiYZQRSTUVWXYZijklmnop'
222
428
 
223
429
        chk_blocks('ABCd efghIjk  L'
224
430
                 , 'AxyzBCn mo pqrstuvwI1 2  L'
225
 
                 , [(0,0,1), (1, 4, 2), (4, 7, 1), (9, 19, 1), (12, 23, 3)])
 
431
                 , [(0,0,1), (1, 4, 2), (9, 19, 1), (12, 23, 3)])
226
432
 
 
433
        # These are rot13 code snippets.
227
434
        chk_blocks('''\
228
 
    get added when you add a file in the directory.
229
 
    """
230
 
    takes_args = ['file*']
231
 
    takes_options = ['no-recurse']
232
 
    
233
 
    def run(self, file_list, no_recurse=False):
234
 
        from bzrlib.add import smart_add, add_reporter_print, add_reporter_null
235
 
        if is_quiet():
236
 
            reporter = add_reporter_null
237
 
        else:
238
 
            reporter = add_reporter_print
239
 
        smart_add(file_list, not no_recurse, reporter)
240
 
 
241
 
 
242
 
class cmd_mkdir(Command):
243
 
'''.splitlines(True)
244
 
, '''\
245
 
    get added when you add a file in the directory.
246
 
 
247
 
    --dry-run will show which files would be added, but not actually 
248
 
    add them.
249
 
    """
250
 
    takes_args = ['file*']
251
 
    takes_options = ['no-recurse', 'dry-run']
252
 
 
253
 
    def run(self, file_list, no_recurse=False, dry_run=False):
254
 
        import bzrlib.add
255
 
 
256
 
        if dry_run:
257
 
            if is_quiet():
258
 
                # This is pointless, but I'd rather not raise an error
259
 
                action = bzrlib.add.add_action_null
260
 
            else:
261
 
                action = bzrlib.add.add_action_print
262
 
        elif is_quiet():
263
 
            action = bzrlib.add.add_action_add
264
 
        else:
265
 
            action = bzrlib.add.add_action_add_and_print
266
 
 
267
 
        bzrlib.add.smart_add(file_list, not no_recurse, action)
268
 
 
269
 
 
270
 
class cmd_mkdir(Command):
 
435
    trg nqqrq jura lbh nqq n svyr va gur qverpgbel.
 
436
    """
 
437
    gnxrf_netf = ['svyr*']
 
438
    gnxrf_bcgvbaf = ['ab-erphefr']
 
439
  
 
440
    qrs eha(frys, svyr_yvfg, ab_erphefr=Snyfr):
 
441
        sebz omeyvo.nqq vzcbeg fzneg_nqq, nqq_ercbegre_cevag, nqq_ercbegre_ahyy
 
442
        vs vf_dhvrg():
 
443
            ercbegre = nqq_ercbegre_ahyy
 
444
        ryfr:
 
445
            ercbegre = nqq_ercbegre_cevag
 
446
        fzneg_nqq(svyr_yvfg, abg ab_erphefr, ercbegre)
 
447
 
 
448
 
 
449
pynff pzq_zxqve(Pbzznaq):
 
450
'''.splitlines(True), '''\
 
451
    trg nqqrq jura lbh nqq n svyr va gur qverpgbel.
 
452
 
 
453
    --qel-eha jvyy fubj juvpu svyrf jbhyq or nqqrq, ohg abg npghnyyl 
 
454
    nqq gurz.
 
455
    """
 
456
    gnxrf_netf = ['svyr*']
 
457
    gnxrf_bcgvbaf = ['ab-erphefr', 'qel-eha']
 
458
 
 
459
    qrs eha(frys, svyr_yvfg, ab_erphefr=Snyfr, qel_eha=Snyfr):
 
460
        vzcbeg omeyvo.nqq
 
461
 
 
462
        vs qel_eha:
 
463
            vs vf_dhvrg():
 
464
                # Guvf vf cbvagyrff, ohg V'q engure abg envfr na reebe
 
465
                npgvba = omeyvo.nqq.nqq_npgvba_ahyy
 
466
            ryfr:
 
467
  npgvba = omeyvo.nqq.nqq_npgvba_cevag
 
468
        ryvs vf_dhvrg():
 
469
            npgvba = omeyvo.nqq.nqq_npgvba_nqq
 
470
        ryfr:
 
471
       npgvba = omeyvo.nqq.nqq_npgvba_nqq_naq_cevag
 
472
 
 
473
        omeyvo.nqq.fzneg_nqq(svyr_yvfg, abg ab_erphefr, npgvba)
 
474
 
 
475
 
 
476
pynff pzq_zxqve(Pbzznaq):
271
477
'''.splitlines(True)
272
478
, [(0,0,1), (1, 4, 2), (9, 19, 1), (12, 23, 3)])
273
479
 
274
 
    def test_cdv_unified_diff(self):
 
480
    def test_patience_unified_diff(self):
275
481
        txt_a = ['hello there\n',
276
482
                 'world\n',
277
483
                 'how are you today?\n']
278
484
        txt_b = ['hello there\n',
279
485
                 'how are you today?\n']
 
486
        unified_diff = bzrlib.patiencediff.unified_diff
 
487
        psm = bzrlib.patiencediff.PatienceSequenceMatcher
280
488
        self.assertEquals([ '---  \n',
281
489
                           '+++  \n',
282
490
                           '@@ -1,3 +1,2 @@\n',
284
492
                           '-world\n',
285
493
                           ' how are you today?\n'
286
494
                          ]
287
 
                          , list(unified_diff(txt_a, txt_b
288
 
                                        , sequencematcher=SequenceMatcher)))
 
495
                          , list(unified_diff(txt_a, txt_b,
 
496
                                 sequencematcher=psm)))
289
497
        txt_a = map(lambda x: x+'\n', 'abcdefghijklmnop')
290
498
        txt_b = map(lambda x: x+'\n', 'abcdefxydefghijklmnop')
291
499
        # This is the result with LongestCommonSubstring matching
304
512
                           ' e\n',
305
513
                           ' f\n']
306
514
                          , list(unified_diff(txt_a, txt_b)))
307
 
        # And the cdv diff
 
515
        # And the patience diff
308
516
        self.assertEquals(['---  \n',
309
517
                           '+++  \n',
310
518
                           '@@ -4,6 +4,11 @@\n',
321
529
                           ' i\n',
322
530
                          ]
323
531
                          , list(unified_diff(txt_a, txt_b,
324
 
                                 sequencematcher=SequenceMatcher)))
325
 
 
326
 
 
327
 
class TestCDVDiffLibFiles(TestCaseInTempDir):
328
 
 
329
 
    def test_cdv_unified_diff_files(self):
 
532
                                 sequencematcher=psm)))
 
533
 
 
534
 
 
535
class TestPatienceDiffLibFiles(TestCaseInTempDir):
 
536
 
 
537
    def test_patience_unified_diff_files(self):
330
538
        txt_a = ['hello there\n',
331
539
                 'world\n',
332
540
                 'how are you today?\n']
335
543
        open('a1', 'wb').writelines(txt_a)
336
544
        open('b1', 'wb').writelines(txt_b)
337
545
 
 
546
        unified_diff_files = bzrlib.patiencediff.unified_diff_files
 
547
        psm = bzrlib.patiencediff.PatienceSequenceMatcher
338
548
        self.assertEquals(['--- a1 \n',
339
549
                           '+++ b1 \n',
340
550
                           '@@ -1,3 +1,2 @@\n',
343
553
                           ' how are you today?\n',
344
554
                          ]
345
555
                          , list(unified_diff_files('a1', 'b1',
346
 
                                 sequencematcher=SequenceMatcher)))
 
556
                                 sequencematcher=psm)))
347
557
 
348
558
        txt_a = map(lambda x: x+'\n', 'abcdefghijklmnop')
349
559
        txt_b = map(lambda x: x+'\n', 'abcdefxydefghijklmnop')
367
577
                           ' f\n']
368
578
                          , list(unified_diff_files('a2', 'b2')))
369
579
 
370
 
        # And the cdv diff
 
580
        # And the patience diff
371
581
        self.assertEquals(['--- a2 \n',
372
582
                           '+++ b2 \n',
373
583
                           '@@ -4,6 +4,11 @@\n',
384
594
                           ' i\n',
385
595
                          ]
386
596
                          , list(unified_diff_files('a2', 'b2',
387
 
                                 sequencematcher=SequenceMatcher)))
 
597
                                 sequencematcher=psm)))