800
800
chk_blocks('abbabbbb', 'cabbabbc', [])
801
801
chk_blocks('bbbbbbbb', 'cbbbbbbc', [])
803
def test_matching_blocks_tuples(self):
804
def chk_blocks(a, b, expected_blocks):
805
# difflib always adds a signature of the total
806
# length, with no matching entries at the end
807
s = self._PatienceSequenceMatcher(None, a, b)
808
blocks = s.get_matching_blocks()
809
self.assertEquals((len(a), len(b), 0), blocks[-1])
810
self.assertEquals(expected_blocks, blocks[:-1])
812
# Some basic matching tests
813
chk_blocks([], [], [])
814
chk_blocks([('a',), ('b',), ('c,')], [], [])
815
chk_blocks([], [('a',), ('b',), ('c,')], [])
816
chk_blocks([('a',), ('b',), ('c,')],
817
[('a',), ('b',), ('c,')],
819
chk_blocks([('a',), ('b',), ('c,')],
820
[('a',), ('b',), ('d,')],
822
chk_blocks([('d',), ('b',), ('c,')],
823
[('a',), ('b',), ('c,')],
825
chk_blocks([('d',), ('a',), ('b',), ('c,')],
826
[('a',), ('b',), ('c,')],
828
chk_blocks([('a', 'b'), ('c', 'd'), ('e', 'f')],
829
[('a', 'b'), ('c', 'X'), ('e', 'f')],
830
[(0, 0, 1), (2, 2, 1)])
831
chk_blocks([('a', 'b'), ('c', 'd'), ('e', 'f')],
832
[('a', 'b'), ('c', 'dX'), ('e', 'f')],
833
[(0, 0, 1), (2, 2, 1)])
803
835
def test_opcodes(self):
804
836
def chk_ops(a, b, expected_codes):
805
837
s = self._PatienceSequenceMatcher(None, a, b)