def _get_message(self, record): try: return record.getMessage(), None except: message = 'Failed to log following message properly: %s' \ % utils.unic(record.msg) error = '\n'.join(utils.get_error_details()) return message, error
def _report_adding_keyword_failed(self, name, message=None, details=None, level=None): if not message: message, details = get_error_details() LOGGER.write("Adding keyword '%s' to library '%s' failed: %s" % (name, self.name, message), level or self._failure_level) if details: LOGGER.debug('Details:\n%s' % details)
def call_method(self, method, *args): try: method(*args) except: message, details = get_error_details() LOGGER.error("Calling listener method '%s' of listener '%s' " "failed: %s" % (method.__name__, self.name, message)) LOGGER.info("Details:\n%s" % details)
def _get_message(self, record): try: return record.getMessage(), None except: message = 'Failed to log following message properly: %s' \ % unic(record.msg) error = '\n'.join(get_error_details()) return message, error
def _raise_creating_instance_failed(self): msg, details = get_error_details() if self.positional_args or self.named_args: args = self.positional_args \ + ['%s=%s' % item for item in self.named_args] args_text = 'arguments %s' % seq2str2(args) else: args_text = 'no arguments' raise DataError("Initializing test library '%s' with %s failed: %s\n%s" % (self.name, args_text, msg, details))
def _raise_creating_instance_failed(self): msg, details = get_error_details() if self.positional_args or self.named_args: args = self.positional_args \ + ['%s=%s' % item for item in self.named_args.items()] args_text = 'arguments %s' % seq2str2(args) else: args_text = 'no arguments' raise DataError("Initializing test library '%s' with %s failed: %s\n%s" % (self.name, args_text, msg, details))
def visit_suite(self, suite): for visitor in self._visitors: try: suite.visit(visitor) except: message, details = get_error_details() self._log_error("Executing model modifier '%s' failed: %s\n%s" % (type_name(visitor), message, details)) if not (suite.test_count or self._empty_suite_ok): raise DataError("Suite '%s' contains no tests after model " "modifiers." % suite.name)
def _close_listener(self, listener): method = (getattr(listener, 'close', None) or getattr(listener, '_close', None)) try: if method: method() except: message, details = get_error_details() name = getattr(listener, '__name__', None) or type_name(listener) LOGGER.error("Calling method '%s' of listener '%s' failed: %s" % (method.__name__, name, message)) LOGGER.info("Details:\n%s" % details)
def visit_suite(self, suite): for visitor in self._visitors: try: suite.visit(visitor) except: message, details = get_error_details() self._log_error( "Executing model modifier '%s' failed: %s\n%s" % (type_name(visitor), message, details)) if not (suite.test_count or self._empty_suite_ok): raise DataError("Suite '%s' contains no tests after model " "modifiers." % suite.name)
def _set_cli_variables(self, settings): for path, args in settings.variable_files: try: path = find_file(path, file_type='Variable file') self.set_from_file(path, args) except: msg, details = get_error_details() LOGGER.error(msg) LOGGER.info(details) for varstr in settings.variables: try: name, value = varstr.split(':', 1) except ValueError: name, value = varstr, '' self['${%s}' % name] = value
def __call__(self, args): if self.called: return try: ListenerMethod.called = True self.method(*args) except TimeoutError: # Propagate possible timeouts: # https://github.com/robotframework/robotframework/issues/2763 raise except: message, details = get_error_details() LOGGER.error("Calling method '%s' of listener '%s' failed: %s" % (self.method.__name__, self.listener_name, message)) LOGGER.info("Details:\n%s" % details) finally: ListenerMethod.called = False
def _create_handlers(self, libcode): try: names = self._get_handler_names(libcode) except: message, details = get_error_details() raise DataError("Getting keyword names from library '%s' failed: %s" % (self.name, message), details) for name in names: method = self._try_to_get_handler_method(libcode, name) if method: handler, embedded = self._try_to_create_handler(name, method) if handler: try: self.handlers.add(handler, embedded) except DataError as err: LOGGER.error("Error in test library '%s': " "Creating keyword '%s' failed: %s" % (self.name, handler.name, err.message)) else: LOGGER.debug("Created keyword '%s'" % handler.name)