def _annotate(self, lines, index, start, end): annotations = [None for _ in lines] DiffHunk._annotate(lines, index, start, end, annotations) return annotations
def test_prettify_header_context_escape(self): hunk = DiffHunk(2, 2, '<h3>Constructing form data set</h3>', []) self.assertNotIn('<h3>', hunk.prettify()) self.assertIn('<h3>', hunk.prettify())
def test_find_operations(self): self.assertEquals(DiffHunk._find_operations([]), []) self.assertEquals(DiffHunk._find_operations([' ']), []) self.assertEquals(DiffHunk._find_operations(['-']), [([0], [])]) self.assertEquals(DiffHunk._find_operations(['-', '-']), [([0, 1], [])]) self.assertEquals(DiffHunk._find_operations([' ', '-', '-']), [([1, 2], [])]) self.assertEquals(DiffHunk._find_operations(['-', '-', ' ']), [([0, 1], [])]) self.assertEquals(DiffHunk._find_operations(['+']), [([], [0])]) self.assertEquals(DiffHunk._find_operations(['+', '+']), [([], [0, 1])]) self.assertEquals(DiffHunk._find_operations([' ', '+', '+']), [([], [1, 2])]) self.assertEquals(DiffHunk._find_operations(['+', '+', ' ']), [([], [0, 1])]) self.assertEquals(DiffHunk._find_operations(['-', '+']), [([0], [1])]) self.assertEquals(DiffHunk._find_operations(['-', '-', '+', '+']), [([0, 1], [2, 3])]) self.assertEquals(DiffHunk._find_operations([' ', '-', '-', '+']), [([1, 2], [3])]) self.assertEquals(DiffHunk._find_operations(['-', '-', '+', '+', ' ']), [([0, 1], [2, 3])]) self.assertEquals(DiffHunk._find_operations(['-', '-', '+', '+', '-']), [([0, 1], [2, 3]), ([4], [])]) self.assertEquals(DiffHunk._find_operations(['-', '+', '-', '+']), [([0], [1]), ([2], [3])])