Soren Hansen | bc1d3a0 | 2011-09-08 13:33:17 +0200 | [diff] [blame] | 1 | import re |
| 2 | |
| 3 | |
| 4 | class KnownIssuesFinder(object): |
| 5 | |
| 6 | 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) |
| 13 | |
| 14 | 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 |