def test_known_values_2(self): rgx = re.compile('(to*)') string = ''' ... ... to to ... ... ''' match = rgx.search(string) self.assertEqual(ulines(tu.pretty_match(match, string)), ''' ... ... to to ^^ ... ...''')
def test_known_values_2(self): rgx = re.compile('(to*)') string = ''' ... ... to to ... ... ''' match = rgx.search(string) self.assertEqual(ulines(tu.pretty_match(match, string)), ''' ... ... to to ^^ ... ...''')
def check_line(line): """check a line for a bad construction if it founds one, return a message describing the problem else return None """ cleanstr = COMMENT_RGX.sub('', STRING_RGX.sub('', line)) for rgx_match, rgx_search, msg_id in BAD_CONSTRUCT_RGXS: if rgx_match.match(cleanstr): string_positions = get_string_coords(line) for match in re.finditer(rgx_search, line): if not in_coords(match, string_positions): return msg_id, pretty_match(match, line.rstrip())
def check_line(line): """check a line for a bad construction if it founds one, return a message describing the problem else return None """ cleanstr = COMMENT_RGX.sub('', STRING_RGX.sub('', line)) for rgx_match, rgx_search, msg_id in BAD_CONSTRUCT_RGXS: if rgx_match.match(cleanstr): string_positions = get_string_coords(line) for match in re.finditer(rgx_search, line): if not in_coords(match, string_positions): return msg_id, pretty_match(match, line.rstrip())
def test_known(self): string = 'hiuherabcdef' self.assertEqual(ulines(tu.pretty_match(RGX.search(string), string)), 'hiuherabcdef\n ^^^^')
def test_known_values_1(self): rgx = re.compile('(to*)') string = 'toto' match = rgx.search(string) self.assertEquals(ulines(tu.pretty_match(match, string)), '''toto ^^''')
def test_known(self): string = 'hiuherabcdef' self.assertEqual(ulines(tu.pretty_match(RGX.search(string), string)), 'hiuherabcdef\n ^^^^')
def test_known_values_1(self): rgx = re.compile('(to*)') string = 'toto' match = rgx.search(string) self.assertEquals(ulines(tu.pretty_match(match, string)), '''toto ^^''')