""" This plugin bypasses the actual execution of tests, and instead just collects test names. Fixtures are also bypassed, so running nosetests with the collection plugin enabled should be very quick.
This plugin is useful in combination with the testid plugin (``--with-id``). Run both together to get an indexed list of all tests, which will enable you to run individual tests by index number.
This plugin is also useful for counting tests in a test suite, and making people watching your demo think all of your tests pass. """
""" Collect and output test names only, don't run any tests. """
"""Register commandline options. """ action='store_true', dest=self.enableOpt, default=env.get('NOSE_COLLECT_ONLY'), help="Enable collect-only: %s [COLLECT_ONLY]" % (self.help()))
"""Install collect-only suite class in TestLoader. """ # Disable context awareness log.debug("Preparing test loader") loader.suiteClass = TestSuiteFactory(self.conf)
"""Replace actual test with dummy that always passes. """ # Return something that always passes log.debug("Preparing test case %s", test) if not isinstance(test, Test): return def run(result): # We need to make these plugin calls because there won't be # a result proxy, due to using a stripped-down test suite self.conf.plugins.startTest(test) result.startTest(test) self.conf.plugins.addSuccess(test) result.addSuccess(test) self.conf.plugins.stopTest(test) result.stopTest(test) return run
""" Factory for producing configured test suites. """ self.conf = conf
return TestSuite(tests, conf=self.conf)
""" Basic test suite that bypasses most proxy and plugin calls, but does wrap tests in a nose.case.Test so prepareTestCase will be called. """ self.conf = conf # Exec lazy suites: makes discovery depth-first if callable(tests): tests = tests() log.debug("TestSuite(%r)", tests) unittest.TestSuite.__init__(self, tests)
log.debug("Add test %s", test) if isinstance(test, unittest.TestSuite): self._tests.append(test) else: self._tests.append(Test(test, config=self.conf))
|