A nose plugin to effect our exclusions of files and directories.
| 238 | |
| 239 | |
| 240 | class ExclusionPlugin(Plugin): |
| 241 | """A nose plugin to effect our exclusions of files and directories. |
| 242 | """ |
| 243 | name = 'exclusions' |
| 244 | score = 3000 # Should come before any other plugins |
| 245 | |
| 246 | def __init__(self, exclude_patterns=None): |
| 247 | """ |
| 248 | Parameters |
| 249 | ---------- |
| 250 | |
| 251 | exclude_patterns : sequence of strings, optional |
| 252 | Filenames containing these patterns (as raw strings, not as regular |
| 253 | expressions) are excluded from the tests. |
| 254 | """ |
| 255 | self.exclude_patterns = exclude_patterns or [] |
| 256 | super(ExclusionPlugin, self).__init__() |
| 257 | |
| 258 | def options(self, parser, env=os.environ): |
| 259 | Plugin.options(self, parser, env) |
| 260 | |
| 261 | def configure(self, options, config): |
| 262 | Plugin.configure(self, options, config) |
| 263 | # Override nose trying to disable plugin. |
| 264 | self.enabled = True |
| 265 | |
| 266 | def wantFile(self, filename): |
| 267 | """Return whether the given filename should be scanned for tests. |
| 268 | """ |
| 269 | if any(pat in filename for pat in self.exclude_patterns): |
| 270 | return False |
| 271 | return None |
| 272 | |
| 273 | def wantDirectory(self, directory): |
| 274 | """Return whether the given directory should be scanned for tests. |
| 275 | """ |
| 276 | if any(pat in directory for pat in self.exclude_patterns): |
| 277 | return False |
| 278 | return None |
| 279 | |
| 280 | |
| 281 | class StreamCapturer(Thread): |