コード例 #1
0
 def test_module_loaded_suite_filters_suite(self):
     self.plugin.attribs = ["a"]
     suite = unittest.TestSuite()
     suite.addTest(self.TC_1("test_a"))
     suite.addTest(self.TC_1("test_b"))
     event = events.ModuleSuiteEvent(None, None, suite)
     self.session.hooks.moduleLoadedSuite(event)
     self.assertEqual(len(event.suite._tests), 1)
     self.assertEqual(event.suite._tests[0]._testMethodName, "test_a")
コード例 #2
0
    def loadTestsFromModule(self, module):
        """Load tests from module.

        Fires :func:`loadTestsFromModule` hook.

        """
        evt = events.LoadFromModuleEvent(self, module)
        result = self.session.hooks.loadTestsFromModule(evt)
        if evt.handled:
            suite = result or self.suiteClass()
        else:
            suite = self.suiteClass(evt.extraTests)
        filterevt = events.ModuleSuiteEvent(self, module, suite)
        result = self.session.hooks.moduleLoadedSuite(filterevt)
        if result:
            return result or self.suiteClass()
        return filterevt.suite