~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_diff.py

Clarify the patience tests a little bit.

Show diffs side-by-side

added added

removed removed

Lines of Context:
97
97
        test_one('aBccDe', 'abccde', [(0,0), (5,5)])
98
98
 
99
99
    def test_matching_blocks(self):
100
 
        def chk_blocks(a, b, matching):
 
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
103
            s = SequenceMatcher(None, a, b)
104
104
            blocks = s.get_matching_blocks()
105
 
            x = blocks.pop()
106
 
            self.assertEquals(x, (len(a), len(b), 0))
107
 
            self.assertEquals(matching, blocks)
 
105
            self.assertEquals((len(a), len(b), 0), blocks[-1])
 
106
            self.assertEquals(expected_blocks, blocks[:-1])
108
107
 
109
108
        # Some basic matching tests
110
109
        chk_blocks('', '', [])
143
142
        chk_blocks('bbbbbbbb', 'cbbbbbbc', [(0,1,6)])
144
143
 
145
144
    def test_opcodes(self):
146
 
        def chk_ops(a, b, codes):
 
145
        def chk_ops(a, b, expected_codes):
147
146
            s = SequenceMatcher(None, a, b)
148
 
            self.assertEquals(codes, s.get_opcodes())
 
147
            self.assertEquals(expected_codes, s.get_opcodes())
149
148
 
150
149
        chk_ops('', '', [])
151
150
        chk_ops([], [], [])
207
206
    def test_multiple_ranges(self):
208
207
        # There was an earlier bug where we used a bad set of ranges,
209
208
        # this triggers that specific bug, to make sure it doesn't regress
210
 
        def chk_blocks(a, b, matching):
 
209
        def chk_blocks(a, b, expected_blocks):
211
210
            # difflib always adds a signature of the total
212
211
            # length, with no matching entries at the end
213
212
            s = SequenceMatcher(None, a, b)
214
213
            blocks = s.get_matching_blocks()
215
214
            x = blocks.pop()
216
215
            self.assertEquals(x, (len(a), len(b), 0))
217
 
            self.assertEquals(matching, blocks)
 
216
            self.assertEquals(expected_blocks, blocks)
218
217
 
219
218
        chk_blocks('abcdefghijklmnop'
220
219
                 , 'abcXghiYZQRSTUVWXYZijklmnop'