def test_only_removals(self): q1 = deque([1, 2]) q2 = deque([]) lcs_marker = () expected_diff_block = Chunk([ DiffItem(remove, 1, (0, 1, 0, 0)), DiffItem(remove, 2, (1, 2, 0, 0)) ]) chunks = chunker( diff_item_data_factory(q1, q2, lcs_marker) ) self.assertEqual(next(chunks), expected_diff_block)
def test_changes_before_the_first_unchanged_item(self): q1 = deque([1, 4]) q2 = deque([2, 4]) lcs_markers = ((1, 1),) chunk = Chunk([ DiffItem(remove, 1, (0, 1, 0, 0)), DiffItem(insert, 2, (1, 1, 0, 1)), DiffItem(unchanged, 4, (1, 2, 1, 2)) ]) chunks = chunker( diff_item_data_factory(q1, q2, lcs_markers) ) self.assertEqual(next(chunks), chunk)
def test_only_unchanged(self): q1 = deque([1, 2]) q2 = deque([1, 2]) lcs_markers = ((0, 0), (1, 1)) chunk_1 = Chunk([ DiffItem(unchanged, 1, (0, 1, 0, 1)) ]) chunk_2 = Chunk([ DiffItem(unchanged, 2, (1, 2, 1, 2)) ]) chunks = chunker( diff_item_data_factory(q1, q2, lcs_markers) ) self.assertEqual(next(chunks), chunk_1) self.assertEqual(next(chunks), chunk_2)
def test_some_changes_after_an_unchanged_item(self): q1 = deque([0, 1, 2]) q2 = deque([0, 3, 4]) lcs_marker = ((0, 0),) chunk_1 = Chunk([ DiffItem(unchanged, 0, (0, 1, 0, 1)) ]) chunk_2 = Chunk([ DiffItem(remove, 1, (1, 2, 1, 1)), DiffItem(remove, 2, (2, 3, 1, 1)), DiffItem(insert, 3, (3, 3, 1, 2)), DiffItem(insert, 4, (3, 3, 2, 3)) ]) chunks = chunker( diff_item_data_factory(q1, q2, lcs_marker) ) self.assertEqual(next(chunks), chunk_1) self.assertEqual(next(chunks), chunk_2)
def test_empty_diff_block(self): chunks = chunker( diff_item_data_factory(deque([]), deque([]), ()) ) self.assertEqual(next(chunks), Chunk())