def test_get_chunks(self): """Testing RawDiffChunkGenerator.get_chunks""" old = (b'This is line 1\n' b'Another line\n' b'Line 3.\n' b'la de da.\n') new = (b'This is line 1\n' b'Line 3.\n' b'la de doo.\n') generator = RawDiffChunkGenerator(old, new, 'file1', 'file2') chunks = list(generator.get_chunks()) self.assertEqual(len(chunks), 4) self.assertEqual(chunks[0]['change'], 'equal') self.assertEqual(chunks[1]['change'], 'delete') self.assertEqual(chunks[2]['change'], 'equal') self.assertEqual(chunks[3]['change'], 'replace')
def test_get_chunks_with_enable_syntax_highlighting_false(self): """Testing RawDiffChunkGenerator.get_chunks with enable_syntax_highlighting=False """ old = b'This is **bold**' new = b'This is *italic*' generator = RawDiffChunkGenerator(old=old, new=new, orig_filename='file1.md', modified_filename='file2.md', enable_syntax_highlighting=False) chunks = list(generator.get_chunks()) self.assertEqual(len(chunks), 1) self.assertEqual( chunks[0], { 'change': 'replace', 'collapsable': False, 'index': 0, 'lines': [ [ 1, 1, 'This is **bold**', [(9, 16)], 1, 'This is *italic*', [(9, 16)], False, ], ], 'meta': { 'left_headers': [], 'right_headers': [], 'whitespace_chunk': False, 'whitespace_lines': [], }, 'numlines': 1, })
def test_get_chunks(self): """Testing RawDiffChunkGenerator.get_chunks""" old = ( b'This is line 1\n' b'Another line\n' b'Line 3.\n' b'la de da.\n' ) new = ( b'This is line 1\n' b'Line 3.\n' b'la de doo.\n' ) generator = RawDiffChunkGenerator(old, new, 'file1', 'file2') chunks = list(generator.get_chunks()) self.assertEqual(len(chunks), 4) self.assertEqual(chunks[0]['change'], 'equal') self.assertEqual(chunks[1]['change'], 'delete') self.assertEqual(chunks[2]['change'], 'equal') self.assertEqual(chunks[3]['change'], 'replace')
def test_get_chunks(self): """Testing RawDiffChunkGenerator.get_chunks""" old = (b'This is line 1\n' b'Another line\n' b'Line 3.\n' b'la de da.\n') new = (b'This is line 1\n' b'Line 3.\n' b'la de doo.\n') generator = RawDiffChunkGenerator(old, new, 'file1', 'file2') chunks = list(generator.get_chunks()) self.assertEqual(len(chunks), 4) self.assertEqual( chunks[0], { 'change': 'equal', 'collapsable': False, 'index': 0, 'lines': [ [ 1, 1, 'This is line 1', [], 1, 'This is line 1', [], False, ], ], 'meta': { 'left_headers': [], 'right_headers': [], 'whitespace_chunk': False, 'whitespace_lines': [], }, 'numlines': 1, }) self.assertEqual( chunks[1], { 'change': 'delete', 'collapsable': False, 'index': 1, 'lines': [ [ 2, 2, 'Another line', [], '', '', [], False, ], ], 'meta': { 'left_headers': [], 'right_headers': [], 'whitespace_chunk': False, 'whitespace_lines': [], }, 'numlines': 1, }) self.assertEqual( chunks[2], { 'change': 'equal', 'collapsable': False, 'index': 2, 'lines': [ [ 3, 3, 'Line 3.', [], 2, 'Line 3.', [], False, ], ], 'meta': { 'left_headers': [], 'right_headers': [], 'whitespace_chunk': False, 'whitespace_lines': [], }, 'numlines': 1, }) self.assertEqual( chunks[3], { 'change': 'replace', 'collapsable': False, 'index': 3, 'lines': [ [ 4, 4, 'la de da.', [(7, 8)], 3, 'la de doo.', [(7, 9)], False, ], ], 'meta': { 'left_headers': [], 'right_headers': [], 'whitespace_chunk': False, 'whitespace_lines': [], }, 'numlines': 1, })