3
# Partly based on a script from Review Board, MIT license; but modified to
6
from __future__ import print_function
6
12
class TestPyflakesClean(unittest.TestCase):
7
13
""" ensure that the tree is pyflakes clean """
15
def read_exclusions(self):
18
with open("pyflakes.exclude", "r") as fp:
20
if not line.startswith("#"):
21
exclusions[line.rstrip()] = 1
26
def filter_exclusions(self, contents):
27
exclusions = self.read_exclusions()
29
if line.startswith("#"):
33
test_line = re.sub(r":[0-9]+:", r":*:", line, 1)
34
test_line = re.sub(r"line [0-9]+", r"line *", test_line)
36
if test_line not in exclusions:
9
39
def test_pyflakes_clean(self):
10
40
# mvo: type -f here to avoid running pyflakes on imported files
11
41
# that are symlinks to other packages
12
42
cmd = 'find .. -type f -name "*.py"|xargs pyflakes'
13
self.assertEqual(subprocess.call(cmd, shell=True), 0)
44
cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
45
close_fds=True, shell=True, universal_newlines=True)
46
contents = p.communicate()[0].splitlines()
47
filtered_contents = list(self.filter_exclusions(contents))
48
for line in filtered_contents:
50
self.assertEqual(0, len(filtered_contents))
15
52
if __name__ == "__main__":