"""This plugin implements :func:`startTestRun`, which excludes all test objectsthat define a ``__test__`` attribute that evaluates to ``False``."""fromunittestimportTestSuitefromnose2importevents__unittest=TrueclassDunderTestFilter(events.Plugin):""" Exclude all tests defining a ``__test__`` attribute that evaluates to ``False``. """alwaysOn=TruedefstartTestRun(self,event):""" Recurse :attr:`event.suite` and remove all test suites and test cases that define a ``__test__`` attribute that evaluates to ``False``. """self.removeNonTests(event.suite)defremoveNonTests(self,suite):fortestinlist(suite):ifnotgetattr(test,'__test__',True):suite._tests.remove(test)elifisinstance(test,TestSuite):self.removeNonTests(test)