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
         ^^
 ... ...''')
Ejemplo n.º 3
0
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())
Ejemplo n.º 4
0
Archivo: format.py Proyecto: DINKIN/XDM
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())
Ejemplo n.º 5
0
 def test_known(self):
     string = 'hiuherabcdef'
     self.assertEqual(ulines(tu.pretty_match(RGX.search(string), string)),
                      'hiuherabcdef\n      ^^^^')
Ejemplo n.º 6
0
    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      ^^^^')
Ejemplo n.º 8
0
    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
^^''')