/usr/lib/python2.6/site-packages/nose/plugins
NameSizeModeActions
attrib.py78100644editdlrm
attrib.pyc74280644editdlrm
attrib.pyo74280644editdlrm
base.py313840644editdlrm
base.pyc368100644editdlrm
base.pyo368100644editdlrm
builtin.py7920644editdlrm
builtin.pyc13690644editdlrm
builtin.pyo13690644editdlrm
capture.py27800644editdlrm
capture.pyc45650644editdlrm
capture.pyo45650644editdlrm
cover.py64160644editdlrm
cover.pyc62130644editdlrm
cover.pyo62130644editdlrm
debug.py16790644editdlrm
debug.pyc24810644editdlrm
debug.pyo24810644editdlrm
deprecated.py16390644editdlrm
deprecated.pyc23850644editdlrm
deprecated.pyo23850644editdlrm
doctests.py91470644editdlrm
doctests.pyc98910644editdlrm
doctests.pyo98910644editdlrm
errorclass.py64380644editdlrm
errorclass.pyc80370644editdlrm
errorclass.pyo80370644editdlrm
failuredetail.py15640644editdlrm
failuredetail.pyc23340644editdlrm
failuredetail.pyo23340644editdlrm
isolate.py36740644editdlrm
isolate.pyc47290644editdlrm
isolate.pyo47290644editdlrm
manager.py143300644editdlrm
manager.pyc183700644editdlrm
manager.pyo183700644editdlrm
plugintest.py79940644editdlrm
plugintest.pyc96440644editdlrm
plugintest.pyo96440644editdlrm
prof.py47440644editdlrm
prof.pyc49330644editdlrm
prof.pyo49330644editdlrm
skip.py15720644editdlrm
skip.pyc22890644editdlrm
skip.pyo22890644editdlrm
testid.py48710644editdlrm
testid.pyc54790644editdlrm
testid.pyo54790644editdlrm
__init__.py81690644editdlrm
__init__.pyc84120644editdlrm
__init__.pyo84120644editdlrm
Edit: /usr/lib/python2.6/site-packages/nose/plugins/testid.py (4871B)
""" This plugin adds a test id (like #1) to each test name output. After you've run once to generate test ids, you can re-run individual tests by activating the plugin and passing the ids (with or without the # prefix) instead of test names. For example, if your normal test run looks like:: % nosetests -v tests.test_a ... ok tests.test_b ... ok tests.test_c ... ok When adding --with-id you'll see:: % nosetests -v --with-id #1 tests.test_a ... ok #2 tests.test_b ... ok #2 tests.test_c ... ok Then you can rerun individual tests by supplying just the id numbers:: % nosetests -v --with-id 2 #2 tests.test_b ... ok Then you can rerun individual tests by supplying just the id numbers:: % nosetests -v --with-id 2 3 #2 tests.test_b ... ok #3 tests.test_c ... ok Since most shells consider '#' a special character, you can leave it out when specifying a test id. """ __test__ = False import logging import os from nose.plugins import Plugin from nose.util import src try: from cPickle import dump, load except ImportError: from pickle import dump, load log = logging.getLogger(__name__) class TestId(Plugin): """ Activate to add a test id (like #1) to each test name output. After you've run once to generate test ids, you can re-run individual tests by activating the plugin and passing the ids (with or without the # prefix) instead of test names. """ name = 'id' idfile = None shouldSave = True def options(self, parser, env): Plugin.options(self, parser, env) parser.add_option('--id-file', action='store', dest='testIdFile', default='.noseids', help="Store test ids found in test runs in this " "file. Default is the file .noseids in the " "working directory.") def configure(self, options, conf): Plugin.configure(self, options, conf) self.idfile = os.path.expanduser(options.testIdFile) if not os.path.isabs(self.idfile): self.idfile = os.path.join(conf.workingDir, self.idfile) self.id = 1 # Ids and tests are mirror images: ids are {id: test address} and # tests are {test address: id} self.ids = {} self.tests = {} # used to track ids seen when tests is filled from # loaded ids file self._seen = {} def finalize(self, result): if self.shouldSave: fh = open(self.idfile, 'w') # save as {id: test address} ids = dict(zip(self.tests.values(), self.tests.keys())) dump(ids, fh) fh.close() log.debug('Saved test ids: %s to %s', ids, self.idfile) def loadTestsFromNames(self, names, module=None): """Translate ids in the list of requested names into their test addresses, if they are found in my dict of tests. """ log.debug('ltfn %s %s', names, module) try: fh = open(self.idfile, 'r') self.ids = load(fh) log.debug('Loaded test ids %s from %s', self.ids, self.idfile) fh.close() except IOError: log.debug('IO error reading %s', self.idfile) return # I don't load any tests myself, only translate names like '#2' # into the associated test addresses result = (None, map(self.tr, names)) if not self.shouldSave: # got some ids in names, so make sure that the ids line # up in output with what I said they were last time self.tests = dict(zip(self.ids.values(), self.ids.keys())) return result def makeName(self, addr): log.debug("Make name %s", addr) filename, module, call = addr if filename is not None: head = src(filename) else: head = module if call is not None: return "%s:%s" % (head, call) return head def setOutputStream(self, stream): self.stream = stream def startTest(self, test): adr = test.address() if adr in self.tests: if self.shouldSave or adr in self._seen: self.stream.write(' ') else: self.stream.write('#%s ' % self.tests[adr]) self._seen[adr] = 1 return self.tests[adr] = self.id self.stream.write('#%s ' % self.id) self.id += 1 def tr(self, name): log.debug("tr '%s'", name) try: key = int(name.replace('#', '')) except ValueError: return name log.debug("Got key %s", key) self.shouldSave = False if key in self.ids: return self.makeName(self.ids[key]) return name