示例#1
0
 def _populate_children(self, datadir, children, include_extensions,
                        include_suites):
     for child in children:
         try:
             datadir.add_child(child, include_suites, include_extensions)
         except NoTestsFound:
             LOGGER.info("Data source '%s' has no tests or tasks." % child)
         except DataError as err:
             LOGGER.error("Parsing '%s' failed: %s" % (child, err.message))
示例#2
0
 def _populate_children(self, datadir, children, include_extensions,
                        include_suites):
     for child in children:
         try:
             datadir.add_child(child, include_suites, include_extensions)
         except NoTestsFound:
             LOGGER.info("Data source '%s' has no tests or tasks." % child)
         except DataError as err:
             LOGGER.error("Parsing '%s' failed: %s" % (child, err.message))
示例#3
0
 def register_listeners(self):
     if self.has_listener:
         try:
             listeners = EXECUTION_CONTEXTS.current.output.library_listeners
             listeners.register(self.get_listeners(), self)
         except DataError as err:
             self.has_listener = False
             # Error should have information about suite where the
             # problem occurred but we don't have such info here.
             LOGGER.error("Registering listeners for library '%s' failed: %s"
                          % (self.name, err))
示例#4
0
 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)
示例#5
0
 def _write(self, name, writer, path, *args):
     try:
         writer(path, *args)
     except DataError as err:
         LOGGER.error(err.message)
     except EnvironmentError as err:
         # `err.filename` can be different than `path` at least if reading
         # log/report templates or writing split log fails.
         # `unic` is needed due to http://bugs.jython.org/issue1825.
         LOGGER.error("Writing %s file '%s' failed: %s: %s" %
                      (name.lower(), path, err.strerror, unic(err.filename)))
     else:
         LOGGER.output_file(name, path)
示例#6
0
 def _get_children(self, dirpath, incl_extensions, incl_suites):
     init_file = None
     children = []
     for path, is_init_file in self._list_dir(dirpath, incl_extensions,
                                              incl_suites):
         if is_init_file:
             if not init_file:
                 init_file = path
             else:
                 LOGGER.error("Ignoring second test suite init file '%s'." % path)
         else:
             children.append(path)
     return init_file, children
示例#7
0
 def _get_children(self, dirpath, incl_extensions, incl_suites):
     init_file = None
     children = []
     for path, is_init_file in self._list_dir(dirpath, incl_extensions,
                                              incl_suites):
         if is_init_file:
             if not init_file:
                 init_file = path
             else:
                 LOGGER.error("Ignoring second test suite init file '%s'." %
                              path)
         else:
             children.append(path)
     return init_file, children
示例#8
0
 def __init__(self, user_keywords, path=None):
     basename = os.path.basename(path) if path else None
     self.name = os.path.splitext(basename)[0] if path else None
     self.handlers = HandlerStore(basename)
     for kw in user_keywords:
         try:
             handler, embedded = self._create_handler(kw)
             self._validate_not_duplicate(handler)
         except DataError as err:
             LOGGER.error("Creating user keyword '%s' failed: %s" %
                          (kw.name, unicode(err)))
             handler = UserErrorHandler(kw.name, unicode(err))
             embedded = False
         self.handlers.add(handler, embedded)
示例#9
0
 def _get_children(self, dirpath, incl_suites):
     init_file = None
     children = []
     for name, path in self._list_dir(dirpath):
         if self._is_init_file(name, path):
             if not init_file:
                 init_file = path
             else:
                 LOGGER.error("Ignoring second test suite init file '%s'." % path)
         elif self._is_included(name, path, incl_suites):
             children.append(path)
         else:
             LOGGER.info("Ignoring file or directory '%s'." % name)
     return init_file, children
示例#10
0
文件: userkeyword.py 项目: Garjy/RIDE
 def __init__(self, user_keywords, path=None):
     basename = os.path.basename(path) if path else None
     self.name = os.path.splitext(basename)[0] if path else None
     self.handlers = HandlerStore(basename)
     for kw in user_keywords:
         try:
             handler, embedded = self._create_handler(kw)
             self._validate_not_duplicate(handler)
         except DataError as err:
             LOGGER.error("Creating user keyword '%s' failed: %s"
                          % (kw.name, unicode(err)))
             handler = UserErrorHandler(kw.name, unicode(err))
             embedded = False
         self.handlers.add(handler, embedded)
 def _get_children(self, dirpath, incl_suites):
     init_file = None
     children = []
     for name, path in self._list_dir(dirpath):
         if self._is_init_file(name, path):
             if not init_file:
                 init_file = path
             else:
                 LOGGER.error("Ignoring second test suite init file '%s'." %
                              path)
         elif self._is_included(name, path, incl_suites):
             children.append(path)
         else:
             LOGGER.info("Ignoring file or directory '%s'." % name)
     return init_file, children
示例#12
0
文件: scopes.py 项目: Garjy/RIDE
 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
示例#13
0
 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
示例#14
0
    def _get_output_file(self, option):
        """Returns path of the requested output file and creates needed dirs.

        `option` can be 'Output', 'Log', 'Report', 'XUnit' or 'DebugFile'.
        """
        name = self._opts[option]
        if not name:
            return None
        if option == 'Log' and self._output_disabled():
            self['Log'] = None
            LOGGER.error('Log file is not created if output.xml is disabled.')
            return None
        name = self._process_output_name(option, name)
        path = abspath(os.path.join(self['OutputDir'], name))
        self._create_output_dir(os.path.dirname(path), option)
        return path
示例#15
0
 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)
示例#16
0
 def _log_creating_failed(self, handler, error):
     LOGGER.error("Error in %s '%s': Creating keyword '%s' failed: %s" %
                  (self.source_type.lower(), self.source, handler.name,
                   error.message))
示例#17
0
 def _populate_init_file(self, datadir, init_file):
     datadir.initfile = init_file
     try:
         FromFilePopulator(datadir).populate(init_file)
     except DataError as err:
         LOGGER.error(err.message)
示例#18
0
 def _table_is_allowed(self, table):
     if table is self.testcase_table:
         LOGGER.error("Test suite init file in '%s' contains a test case "
                      "table which is not allowed." % self.source)
         return False
     return True
示例#19
0
 def _log_creating_failed(self, handler, error):
     LOGGER.error("Error in %s '%s': Creating keyword '%s' failed: %s"
                  % (self.source_type.lower(), self.source,
                     handler.name, error.message))
示例#20
0
 def _populate_init_file(self, datadir, init_file):
     datadir.initfile = init_file
     try:
         FromFilePopulator(datadir).populate(init_file)
     except DataError as err:
         LOGGER.error(err.message)
示例#21
0
 def _table_is_allowed(self, table):
     if table is self.testcase_table:
         LOGGER.error("Test suite initialization file in '%s' cannot "
                      "contain tests or tasks." % self.source)
         return False
     return True
 def _table_is_allowed(self, table):
     if table is self.testcase_table:
         LOGGER.error("Test suite initialization file in '%s' cannot "
                      "contain tests or tasks." % self.source)
         return False
     return True
示例#23
0
文件: model.py 项目: Garjy/RIDE
 def _table_is_allowed(self, table):
     if table is self.testcase_table:
         LOGGER.error("Test suite init file in '%s' contains a test case "
                      "table which is not allowed." % self.source)
         return False
     return True