def set_test_result(self, test_id, result_state, output, when, outcome, exc_type=None, exc_value=None, extracted_traceback=None, last_failed_exempt=None): """ Set test result in internal dictionary. Updates UI. Args: test_id: An unique string test identifier. """ update_listbox = False if test_id not in self.test_data: self.test_data[test_id] = {'id': test_id} update_listbox = True if extracted_traceback: py_traceback = Traceback.from_dict( extracted_traceback).as_traceback() extracted_traceback = traceback.extract_tb(py_traceback) output += ''.join( traceback.format_list(extracted_traceback) + [exc_value]) test_data = self.test_data[test_id] test_data['exc_type'] = exc_type test_data['exc_value'] = exc_value test_data['exc_tb'] = extracted_traceback if when == 'call' and last_failed_exempt is not None: test_data['last_failed_exempt'] = last_failed_exempt # Ignore success, except for the 'call' step # ignore successive failure, take only the first if ((outcome != 'passed' or when == 'call') and not test_data.get('result_state')): test_data['result_state'] = result_state test_data['output'] = output if update_listbox: self.ui.init_test_listbox() else: self.ui.update_test_result(test_data) if when == 'teardown': test_data['runstate'] = None self.ui.update_test_line(test_data)
def on_next(self, msg: Message): type_ = msg.contents.get('type') # self.logger.debug(' type: %s', type_) if type_ is None: return elif type_ != 'log': return # remove unused 'type' value msg.contents.pop('type') # NOTE: Fixes formatting issue used by logging lib, I.E. msg % args args = msg.contents['args'] if isinstance(args, list): msg.contents['args'] = tuple(args) else: msg.contents['args'] = args exc_info = msg.contents['exc_info'] # deserialize exc_info if exc_info: import traceback # FIXME traceback.print_tb(Traceback.from_dict(exc_info).as_traceback()) return # exc_info = (None, None, Traceback.from_dict(exc_info[2]).as_traceback()) """ new_exc_info = [] # Exception type # FIXME: bad exception handeling try: type_ = globals()['__builtins__'][exc_info[0]] # pass in excption arguments value = type_(*exc_info[1]) traceback = Traceback.from_dict(exc_info[2]).as_traceback() new_exc_info = [type_, value, traceback] msg.contents['exc_info'] = new_exc_info except KeyError: # FIXME pass """ # overwrite the member record = logging.LogRecord(**msg.contents) if self.passthrough: self.root.handle(record) else: if record.levelno >= self.root.level: self.root.handle(record)