def test_at_line(self, testnr, data, expected): "at_line returns line number and span for a given sub-line char span" lines = get_lines(data) pos = data.index("FOO") line_number, line_offset, line_width = at_line(pos, 3, data, lines) self.assertEquals(line_number, expected[0]) self.assertEquals(line_offset, expected[1]) self.assertEquals(line_width, expected[2])
def test_get_tagged_comment(self, testnr, data, expected): lines = get_lines(data) offset = data.index("TODO") width = 4 tag_line, line_offset, line_width = at_line(offset, width, data, lines) comment_flavour, char_span, descr_span, line_span = get_tagged_comment( offset, width, data, lines, self.rc.comment_flavours, self.mb ) # Verify test self.assertEquals(data[slice(*expected[1])].strip("/*#\n"), " TODO comment ") # Actual tests self.assertEquals(comment_flavour, expected[0]) self.assertEquals(char_span, expected[1]) self.assertEquals(line_span, expected[2]) self.assertEquals(data[slice(*descr_span)].strip("\n "), "TODO comment") self.assertEquals(data[slice(*descr_span)].strip("/*\n "), "TODO comment")
def test_4_get_tagged_comment(self, testnr, data, expected): lines = get_lines(data) offset = data.index('TODO') width = 4 tag_line, line_offset, line_width, linecnt = at_line(offset, width, data, lines) comment_flavour, char_span, descr_span, line_span = get_tagged_comment( offset, width, data, lines, self.rc.comment_flavours, self.rc.ignored_scans, self.mb) # Verify test (ever case should have same str result) self.assertEquals( data[slice(*expected[1])].strip('/*#\n'), ' TODO comment ' ) # Actual tests self.assertEquals( comment_flavour, expected[0] ) self.assertEquals( char_span, expected[1] ) self.assertEquals( line_span, expected[2] ) self.assertEquals( data[slice(*descr_span)].strip('\n '), 'TODO comment' ) self.assertEquals( data[slice(*descr_span)].strip('/*\n '), 'TODO comment' )