/usr/share/pyshared/nose2/plugins/collect.py is in python-nose2 0.4.7-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | """
This plugin implements :func:`startTestRun`, setting a test executor
(``event.executeTests``) that just collects tests without executing
them. To do so it calls result.startTest, result.addSuccess and
result.stopTest for ech test, without calling the test itself.
"""
from nose2.events import Plugin
from nose2.compat import unittest
__unittest = True
class CollectOnly(Plugin):
"""Collect but don't run tests"""
configSection = 'collect-only'
commandLineSwitch = (None, 'collect-only',
'Collect and output test names, do not run any tests')
_mpmode = False
def registerInSubprocess(self, event):
event.pluginClasses.append(self.__class__)
self._mpmode = True
def startTestRun(self, event):
"""Replace event.executeTests"""
if self._mpmode:
return
event.executeTests = self.collectTests
def startSubprocess(self, event):
event.executeTests = self.collectTests
def collectTests(self, suite, result):
"""Collect tests but don't run them"""
for test in suite:
if isinstance(test, unittest.TestSuite):
self.collectTests(test, result)
continue
result.startTest(test)
result.addSuccess(test)
result.stopTest(test)
|