~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_diff.py

Rename patiencediff.SequenceMatcher => PatienceSequenceMatcher and knit.SequenceMatcher => KnitSequenceMatcher

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 
3
3
from bzrlib.diff import internal_diff
4
4
from bzrlib.errors import BinaryFile
5
 
from bzrlib.patiencediff import (recurse_matches, SequenceMatcher, unique_lcs,
 
5
from bzrlib.patiencediff import (recurse_matches, PatienceSequenceMatcher, unique_lcs,
6
6
                                 unified_diff, unified_diff_files)
7
7
from bzrlib.tests import TestCase, TestCaseInTempDir
8
8
 
100
100
        def chk_blocks(a, b, expected_blocks):
101
101
            # difflib always adds a signature of the total
102
102
            # length, with no matching entries at the end
103
 
            s = SequenceMatcher(None, a, b)
 
103
            s = PatienceSequenceMatcher(None, a, b)
104
104
            blocks = s.get_matching_blocks()
105
105
            self.assertEquals((len(a), len(b), 0), blocks[-1])
106
106
            self.assertEquals(expected_blocks, blocks[:-1])
143
143
 
144
144
    def test_opcodes(self):
145
145
        def chk_ops(a, b, expected_codes):
146
 
            s = SequenceMatcher(None, a, b)
 
146
            s = PatienceSequenceMatcher(None, a, b)
147
147
            self.assertEquals(expected_codes, s.get_opcodes())
148
148
 
149
149
        chk_ops('', '', [])
209
209
        def chk_blocks(a, b, expected_blocks):
210
210
            # difflib always adds a signature of the total
211
211
            # length, with no matching entries at the end
212
 
            s = SequenceMatcher(None, a, b)
 
212
            s = PatienceSequenceMatcher(None, a, b)
213
213
            blocks = s.get_matching_blocks()
214
214
            x = blocks.pop()
215
215
            self.assertEquals(x, (len(a), len(b), 0))
284
284
                           ' how are you today?\n'
285
285
                          ]
286
286
                          , list(unified_diff(txt_a, txt_b
287
 
                                        , sequencematcher=SequenceMatcher)))
 
287
                                        , sequencematcher=PatienceSequenceMatcher)))
288
288
        txt_a = map(lambda x: x+'\n', 'abcdefghijklmnop')
289
289
        txt_b = map(lambda x: x+'\n', 'abcdefxydefghijklmnop')
290
290
        # This is the result with LongestCommonSubstring matching
320
320
                           ' i\n',
321
321
                          ]
322
322
                          , list(unified_diff(txt_a, txt_b,
323
 
                                 sequencematcher=SequenceMatcher)))
 
323
                                 sequencematcher=PatienceSequenceMatcher)))
324
324
 
325
325
 
326
326
class TestCDVDiffLibFiles(TestCaseInTempDir):
342
342
                           ' how are you today?\n',
343
343
                          ]
344
344
                          , list(unified_diff_files('a1', 'b1',
345
 
                                 sequencematcher=SequenceMatcher)))
 
345
                                 sequencematcher=PatienceSequenceMatcher)))
346
346
 
347
347
        txt_a = map(lambda x: x+'\n', 'abcdefghijklmnop')
348
348
        txt_b = map(lambda x: x+'\n', 'abcdefxydefghijklmnop')
383
383
                           ' i\n',
384
384
                          ]
385
385
                          , list(unified_diff_files('a2', 'b2',
386
 
                                 sequencematcher=SequenceMatcher)))
 
386
                                 sequencematcher=PatienceSequenceMatcher)))