def test_thread_generator_tb(self):
        class FakeModel(object):
            def __init__(self, thread_id, tb):
                self.traceback = tb

        with mock.patch('oslo_reports.models'
                        '.threading.ThreadModel', FakeModel):
            model = os_tgen.ThreadReportGenerator("fake traceback")()
            curr_thread = model.get(threading.current_thread().ident, None)
            self.assertIsNotNone(curr_thread, None)
            self.assertEqual("fake traceback", curr_thread.traceback)
    def test_thread_generator(self):
        model = os_tgen.ThreadReportGenerator()()
        # self.assertGreaterEqual(len(model.keys()), 1)
        self.assertTrue(len(model.keys()) >= 1)
        was_ok = False
        for val in model.values():
            self.assertIsInstance(val, os_tmod.ThreadModel)
            self.assertIsNotNone(val.stack_trace)
            if val.thread_id == threading.current_thread().ident:
                was_ok = True
                break

        self.assertTrue(was_ok)

        model.set_current_view_type('text')
        self.assertIsNotNone(six.text_type(model))
예제 #3
0
    def _readd_sections(self):
        del self.sections[self.start_section_index:]

        self.add_section('Package',
                         pgen.PackageReportGenerator(self.version_obj))

        self.add_section('Threads', tgen.ThreadReportGenerator(self.traceback))

        self.add_section('Green Threads', tgen.GreenThreadReportGenerator())

        self.add_section('Processes', prgen.ProcessReportGenerator())

        self.add_section('Configuration', cgen.ConfigReportGenerator())

        try:
            for section_title, generator in self.persistent_sections:
                self.add_section(section_title, generator)
        except AttributeError:
            pass