# HG changeset patch # User Benoit Boissinot # Date 1268926323 -3600 # Node ID 62b8f15683f24532516e8e4d175b5975099f3aac # Parent bedef1c228d3ad9aa43bbb40a953cab5f154af07 check-code: more tests and more robust python filtering diff -r bedef1c228d3 -r 62b8f15683f2 contrib/check-code.py --- a/contrib/check-code.py Thu Mar 18 01:59:53 2010 +0100 +++ b/contrib/check-code.py Thu Mar 18 16:32:03 2010 +0100 @@ -14,6 +14,12 @@ t = re.sub(r"[^\sx]", "o", t) return m.group('quote') + t + m.group('quote') +def reppython(m): + comment = m.group('comment') + if comment: + return "#" * len(comment) + return repquote(m) + def repcomment(m): return m.group(1) + "#" * len(m.group(2)) @@ -96,10 +102,10 @@ ] pyfilters = [ - (r"""(?msx)(?P('''|\"\"\"|(?(.*?)) - (?\#.*?$)| + ((?P('''|\"\"\"|(?(([^\\]|\\.)*?)) + (?P=quote))""", reppython), ] cpats = [ diff -r bedef1c228d3 -r 62b8f15683f2 tests/test-check-code --- a/tests/test-check-code Thu Mar 18 01:59:53 2010 +0100 +++ b/tests/test-check-code Thu Mar 18 16:32:03 2010 +0100 @@ -13,11 +13,13 @@ EOF cat > quote.py < return ( 5+6, 9) missing whitespace in expression gratuitous whitespace in () or [] -./quote.py:4: +./quote.py:5: > '"""', 42+1, """and missing whitespace in expression