blob: 26f20b9126fc0763489cbeb6fbc0d0c601dd4fdd [file] [log] [blame]
Soren Hansenbc1d3a02011-09-08 13:33:17 +02001import re
2
3
4class KnownIssuesFinder(object):
Hengqing Hu9bf93ba2012-03-03 12:21:06 +08005
Soren Hansenbc1d3a02011-09-08 13:33:17 +02006 def __init__(self):
7 self.count = 0
8 self._pattern = re.compile('# *KNOWN-ISSUE')
9
10 def find_known_issues(self, package):
11 for file in self._find_test_module_files(package):
12 self._count_known_issues(file)
Hengqing Hu9bf93ba2012-03-03 12:21:06 +080013
Soren Hansenbc1d3a02011-09-08 13:33:17 +020014 def _find_test_module_files(self, package):
15 for name in dir(package):
16 if name.startswith('test'):
17 module = getattr(package, name)
18 yield module.__file__
19
20 def _count_known_issues(self, file):
21 if file.endswith('.pyc') or file.endswith('.pyo'):
22 file = file[0:-1]
23 for line in open(file):
24 if self._pattern.search(line) is not None:
25 self.count += 1