<commit_before>from nose2 import events, loader, session
from nose2.tests._common import TestCase


class TestPluggableTestLoader(TestCase):

    def setUp(self):
        self.session = session.Session()
        self.loader = loader.PluggableTestLoader(self.session)

    def test_load_from_module_calls_hook(self):
        self.session.hooks.register('loadTestsFromModule', FakePlugin())
        evt = events.LoadFromModuleEvent(self.loader, 'some_module')
        self.session.hooks.loadTestsFromModule(evt)
        self.assertTrue(evt.fakeLoadFromModule,
                        "FakePlugin.loadTestsFromModule() was not called")

    def test_load_from_name_calls_hook(self):
        self.session.hooks.register('loadTestsFromName', FakePlugin())
        evt = events.LoadFromNameEvent(self.loader,
                                       'some_name',
                                       'some_module')
        self.session.hooks.loadTestsFromName(evt)
        self.assertTrue(evt.fakeLoadFromName,
                        "FakePlugin.fakeLoadFromName() was not called")

    def test_load_from_names_calls_hook(self):
        self.session.hooks.register('loadTestsFromNames', FakePlugin())
        evt = events.LoadFromNamesEvent(self.loader,<commit_msg>Add unit tests for loader's _makeFailedTest method<commit_after>from nose2 import events, loader, session
from nose2.tests._common import TestCase


class TestPluggableTestLoader(TestCase):

    def setUp(self):
        self.session = session.Session()
        self.loader = loader.PluggableTestLoader(self.session)

    def test_failed_load_tests_exception(self):
        suite = self.loader.failedLoadTests('test', RuntimeError('err'))
        tc = suite._tests[0]
        with self.assertRaises(RuntimeError) as cm:
            tc.test()
        self.assertEqual(cm.exception.args, ('err', ))

    def test_failed_load_tests_exc_info(self):
        suite = self.loader.failedLoadTests(
            'test', (RuntimeError, RuntimeError('err'), None))
        tc = suite._tests[0]
        with self.assertRaises(RuntimeError) as cm:
            tc.test()
        self.assertEqual(cm.exception.args, ('err', ))

    def test_load_from_module_calls_hook(self):
        self.session.hooks.register('loadTestsFromModule', FakePlugin())
        evt = events.LoadFromModuleEvent(self.loader, 'some_module')
        self.session.hooks.loadTestsFromModule(evt)
        self.assertTrue(evt.fakeLoadFromModule,
                        "FakePlugin.loadTestsFromModule() was not called")

    def test_load_from_name_calls_hook(self):
        self.session.hooks.register('loadTestsFromName', FakePlugin())
        evt = events.LoadFromNameEvent(self.loader,
                                       'some_name',
                                       'some_module')
        self.session.hooks.loadTestsFromName(evt)
        self.assertTrue(evt.fakeLoadFromName,
                        "FakePlugin.fakeLoadFromName() was not called")

    def test_load_from_names_calls_hook(self):
        self.session.hooks.register('loadTestsFromNames', FakePlugin())
        evt = events.LoadFromNamesEvent(self.loader,
{'fraction_non_alphanumeric': 0.09927053599746273, 'fraction_numerical': 0.0019029495718363464, 'mean_word_length': 2.772727272727273, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3494370', 'n_tokens_mistral': 877, 'n_tokens_neox': 889, 'n_words': 138}