Filters tests based on command-line arguments. args can be a glob: asterisks in any position of the name represent zero or more characters. Without asterisks, only exact matches will be used with the exeption of the test-suite name as argument.
| 62 | |
| 63 | |
| 64 | class NameFilterProc(base.TestProcFilter): |
| 65 | """Filters tests based on command-line arguments. |
| 66 | |
| 67 | args can be a glob: asterisks in any position of the name |
| 68 | represent zero or more characters. Without asterisks, only exact matches |
| 69 | will be used with the exeption of the test-suite name as argument. |
| 70 | """ |
| 71 | def __init__(self, args): |
| 72 | super(NameFilterProc, self).__init__() |
| 73 | |
| 74 | self._globs = defaultdict(list) |
| 75 | self._exact_matches = defaultdict(dict) |
| 76 | for a in args: |
| 77 | argpath = a.split('/') |
| 78 | suitename = argpath[0] |
| 79 | path = '/'.join(argpath[1:]) or '*' |
| 80 | if '*' in path: |
| 81 | self._globs[suitename].append(path) |
| 82 | else: |
| 83 | self._exact_matches[suitename][path] = True |
| 84 | |
| 85 | for s, globs in list(self._globs.items()): |
| 86 | if not globs or '*' in globs: |
| 87 | self._globs[s] = ['*'] |
| 88 | |
| 89 | def _filter(self, test): |
| 90 | globs = self._globs.get(test.suite.name, []) |
| 91 | for g in globs: |
| 92 | if g == '*': return False |
| 93 | if fnmatch.fnmatch(test.name, g): |
| 94 | return False |
| 95 | |
| 96 | exact_matches = self._exact_matches.get(test.suite.name, {}) |
| 97 | return test.name not in exact_matches |
no outgoing calls
no test coverage detected
searching dependent graphs…