Mercurial > public > mercurial-scm > hg-stable
diff tests/filterpyflakes.py @ 21271:4adc090fa2fb
tests: ignore "undefined name 'memoryview'" pyflakes error on earlier Python
Before this patch, "test-check-pyflakes.t" shows unexpected "undefined
name 'memoryview'" error for "mercurial/util.py" on Python 2.6.x or
earlier, because they don't define symbol 'memoryview'.
This patch introduces excluding patterns into "filterpyflakes.py" to
ignore "undefined name 'memoryview'" pyflakes error on Python 2.6.x or
earlier
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Fri, 09 May 2014 08:44:53 +0900 |
parents | 0768cda8b579 |
children | 507ce509fd22 |
line wrap: on
line diff
--- a/tests/filterpyflakes.py Fri May 09 08:44:53 2014 +0900 +++ b/tests/filterpyflakes.py Fri May 09 08:44:53 2014 +0900 @@ -29,13 +29,16 @@ for line in sys.stdin: # We whitelist tests (see more messages in pyflakes.messages) pats = [ - r"imported but unused", - r"local variable '.*' is assigned to but never used", - r"unable to detect undefined names", - r"undefined name '.*'", + (r"imported but unused", None), + (r"local variable '.*' is assigned to but never used", None), + (r"unable to detect undefined names", None), ] - for msgtype, pat in enumerate(pats): - if re.search(pat, line): + if sys.version_info >= (2, 7): + pats.append((r"undefined name '.*'", None)) + else: + pats.append((r"undefined name '.*'", r"undefined name 'memoryview'")) + for msgtype, (pat, excl) in enumerate(pats): + if re.search(pat, line) and (not excl or not re.search(excl, line)): break # pattern matches else: continue # no pattern matched, next line @@ -50,3 +53,7 @@ for msgtype, line in sorted(lines, key=makekey): sys.stdout.write(line) print + +# self test of "undefined name" detection for other than 'memoryview' +if False: + print undefinedname