def test_append_deleted_line(self): hunk = Hunk(src_len=1, tgt_len=0) hunk.append_deleted_line(self.sample_line) self.assertTrue(hunk.is_valid()) self.assertEqual(len(hunk.source_lines), 1) self.assertEqual(hunk.target_lines, []) self.assertIn(self.sample_line, hunk.source_lines)
def test_modified_counter(self): hunk = Hunk(src_len=1, tgt_len=1) hunk.append_deleted_line(self.sample_line) hunk.append_added_line(self.sample_line) hunk.add_to_modified_counter(1) self.assertTrue(hunk.is_valid()) self.assertEqual(hunk.modified, 1) self.assertEqual(hunk.added, 0) self.assertEqual(hunk.deleted, 0)
def test_missing_data_is_not_valid(self): hunk = Hunk(src_len=1, tgt_len=1) self.assertFalse(hunk.is_valid())
def test_default_is_valid(self): hunk = Hunk() self.assertTrue(hunk.is_valid())
def test_is_modified_file(self): hunk = Hunk(src_start=1, src_len=10, tgt_start=1, tgt_len=8) self.patched_file.append(hunk) self.assertTrue(self.patched_file.is_modified_file)
def test_is_deleted_file(self): hunk = Hunk(src_start=1, src_len=10, tgt_start=0, tgt_len=0) self.patched_file.append(hunk) self.assertTrue(self.patched_file.is_deleted_file)