Exemple #1
0
 def _annotate(self, lines, index, start, end):
     annotations = [None for _ in lines]
     DiffHunk._annotate(lines, index, start, end, annotations)
     return annotations
Exemple #2
0
 def test_prettify_header_context_escape(self):
     hunk = DiffHunk(2, 2, '<h3>Constructing form data set</h3>', [])
     self.assertNotIn('<h3>', hunk.prettify())
     self.assertIn('&lt;h3&gt;', hunk.prettify())
Exemple #3
0
    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])])