class Nostrils(Plugin): name = 'nostrils' def __init__(self): super(Nostrils, self).__init__() self._tracer = None self._collector = None def configure(self, options, conf): super(Nostrils, self).configure(options, conf) if self.enabled: whitelist = ( '*' if options.whitelist == '*' else options.whitelist.split(',') ) self._collector = TraceCollector(whitelist) self._tracer = Tracer(self._collector) def _print(self): data = self._collector._data for filename in data: print "File: %s" % filename for lineno in sorted(data[filename].keys()): line = linecache.getline(filename, lineno) print "%s%s: %s" % (' ' * 2, lineno, line.rstrip()) for testid in data[filename][lineno]: print "%s* %s" % (' ' * 4, self._collector.get_test_case_name_by_id(testid)) print "\n" def add_options(self, parser, env=None): super(Nostrils, self).add_options(parser, env) parser.add_option( '--nostrils-whitelist', dest='whitelist', help=( 'A comma separated list of top-level folders to be included, ' 'or "*" indicating "all".' ), default='*') def _stop_tracer(self, *args, **kwargs): self._tracer.stop() addError = _stop_tracer addFailure = _stop_tracer addSkip = _stop_tracer addSuccess = _stop_tracer def startTest(self, test): self._collector.current_test = test self._tracer.start() def finalize(self, result): self._print() self._collector.save()
def configure(self, options, conf): super(Nostrils, self).configure(options, conf) if self.enabled: whitelist = ( '*' if options.whitelist == '*' else options.whitelist.split(',') ) self._collector = TraceCollector(whitelist) self._tracer = Tracer(self._collector)