def test_get_all_objects(self, stubs, monkeypatch): # pylint: disable=unused-variable widgets = [self.Object('Widget 1'), self.Object('Widget 2')] app = stubs.FakeQApplication(all_widgets=widgets) monkeypatch.setattr(debug, 'QApplication', app) root = QObject() o1 = self.Object('Object 1', root) o2 = self.Object('Object 2', o1) # noqa: F841 o3 = self.Object('Object 3', root) # noqa: F841 expected = textwrap.dedent(""" Qt widgets - 2 objects: <Widget 1> <Widget 2> Qt objects - 3 objects: <Object 1> <Object 2> <Object 3> global object registry - 0 objects: """).rstrip('\n') assert debug.get_all_objects(start_obj=root) == expected
def report(self): """Report a bug in glimpsebrowser.""" pages = self._recover_pages() cmd_history = objreg.get('command-history')[-5:] objects = debug.get_all_objects() self._crash_dialog = crashdialog.ReportDialog(pages, cmd_history, objects) self._crash_dialog.show()
def _get_exception_info(self): """Get info needed for the exception hook/dialog. Return: An ExceptionInfo object. """ try: pages = self._recover_pages(forgiving=True) except Exception as e: log.destroy.exception("Error while recovering pages: {}".format(e)) pages = [] try: cmd_history = objreg.get('command-history')[-5:] except Exception as e: log.destroy.exception("Error while getting history: {}".format(e)) cmd_history = [] try: objects = debug.get_all_objects() except Exception: log.destroy.exception("Error while getting objects") objects = "" return ExceptionInfo(pages, cmd_history, objects)
def test_get_all_objects_qapp(self): objects = debug.get_all_objects() event_dispatcher = '<PyQt5.QtCore.QAbstractEventDispatcher object at' session_manager = '<PyQt5.QtGui.QSessionManager object at' assert event_dispatcher in objects or session_manager in objects
def debug_all_objects(): """Print a list of all objects to the debug log.""" s = debug.get_all_objects() log.misc.debug(s)