188
189
self.assertEqual(count, len(mod_lines))
191
def test_iter_patched_from_hunks(self):
192
"""Test a few patch files, and make sure they work."""
194
('diff-2', 'orig-2', 'mod-2'),
195
('diff-3', 'orig-3', 'mod-3'),
196
('diff-4', 'orig-4', 'mod-4'),
197
('diff-5', 'orig-5', 'mod-5'),
198
('diff-6', 'orig-6', 'mod-6'),
200
for diff, orig, mod in files:
201
parsed = parse_patch(self.datafile(diff))
202
orig_lines = list(self.datafile(orig))
203
mod_lines = list(self.datafile(mod))
204
iter_patched = iter_patched_from_hunks(orig_lines, parsed.hunks)
205
patched_file = IterableFile(iter_patched)
208
for patch_line in patched_file:
209
self.assertEqual(patch_line, mod_lines[count])
211
self.assertEqual(count, len(mod_lines))
190
213
def testFirstLineRenumber(self):
191
214
"""Make sure we handle lines at the beginning of the hunk"""
192
215
patch = parse_patch(self.datafile("insert_top.patch"))