예제 #1
0
 def run(self, *args):
     raise DataError(self.error)
예제 #2
0
 def _raise(self, error):
     raise DataError('Cannot set variables: %s' % error)
예제 #3
0
 def _raise_replacing_vars_failed(self, import_setting, err):
     raise DataError("Replacing variables from setting '%s' failed: %s"
                     % (import_setting.type, err.message))
 def _validate_var_name(self, name):
     if not is_var(name):
         raise DataError("Invalid variable name '%s'." % name)
예제 #5
0
 def _valid_table(self, table):
     if table is self.testcase_table:
         raise DataError('Test case table not allowed in resource file.')
     return table
예제 #6
0
 def _raise_wrong_variable_count(self, variables, values):
     raise DataError(
         'Number of FOR IN ENUMERATE loop values should be multiple of '
         'its variables (excluding the index). Got %d variables but %d '
         'value%s.' % (variables, values, s(values)))
예제 #7
0
 def validate(self, options, arguments):
     if ConsoleViewer.handles(arguments[1]):
         ConsoleViewer.validate_command(arguments[1], arguments[2:])
     elif len(arguments) > 2:
         raise DataError('Only two arguments allowed when writing output.')
     return options, arguments
예제 #8
0
 def _validate_not_importing_init_file(self, path):
     name = os.path.splitext(os.path.basename(path))[0]
     if name.lower() == '__init__':
         raise DataError("Initialization file '%s' cannot be imported as "
                         "a resource file." % path)
예제 #9
0
 def validate_command(cls, command, args):
     if not cls.handles(command):
         raise DataError("Unknown command '%s'." % command)
     if command.lower() == 'version' and args:
         raise DataError("Command 'version' does not take arguments.")
예제 #10
0
 def _no_library_found(self, name, multiple=False):
     if multiple:
         raise DataError("Multiple libraries matching '%s' found." % name)
     raise DataError("No library '%s' found." % name)
예제 #11
0
 def _raise_multiple_keywords_found(self, name, found, implicit=True):
     error = "Multiple keywords with name '%s' found" % name
     if implicit:
         error += ". Give the full name of the keyword you want to use"
     names = sorted(handler.longname for handler in found)
     raise DataError('\n    '.join([error+':'] + names))
예제 #12
0
 def _get_handler_method(self, libcode, name):
     method = _BaseTestLibrary._get_handler_method(self, libcode, name)
     if hasattr(libcode, '__all__') and name not in libcode.__all__:
         raise DataError('Not exposed as a keyword')
     return method
예제 #13
0
 def _validate_handler(self, handler):
     if not self._is_routine(handler):
         raise DataError('Not a method or function')
     if self._is_implicit_java_or_jython_method(handler):
         raise DataError('Implicit methods are ignored')
예제 #14
0
 def _get_handler_method(self, libcode, name):
     method = getattr(libcode, name)
     if not inspect.isroutine(method):
         raise DataError('Not a method or function')
     return method
예제 #15
0
 def _raise_wrong_variable_count(self, variables, values):
     raise DataError(
         'Number of FOR loop values should be multiple of its variables. '
         'Got %d variables but %d value%s.' %
         (variables, values, s(values)))
예제 #16
0
 def _replace_variables(self, values, variables):
     try:
         return DotDict(self._yield_replaced(values,
                                             variables.replace_scalar))
     except TypeError as err:
         raise DataError('Creating dictionary failed: %s' % err)
예제 #17
0
 def _resolve_dict_values(self, values):
     raise DataError(
         'FOR IN ZIP loops do not support iterating over dictionaries.')
예제 #18
0
 def _raise_invalid(self, option, error):
     raise DataError(f"Invalid value for option '--{option.lower()}': {error}")
예제 #19
0
 def __enter__(self):
     raise DataError(self.reason)
예제 #20
0
 def _parse_args(self, args):
     args = [self._lowercase_long_option(a) for a in args]
     try:
         opts, args = getopt.getopt(args, self._short_opts, self._long_opts)
     except getopt.GetoptError, err:
         raise DataError(err.msg)
예제 #21
0
 def _verify_format(self, type, format, valid):
     format = format.upper()
     if format not in valid:
         raise DataError("%s must be %s, got '%s'."
                         % (type, seq2str(valid, lastsep=' or '), format))
     return format
예제 #22
0
 def _validate_format(self, format):
     format = format.lower() if format else ''
     if format and format not in self._formats:
         raise DataError('Invalid format: %s' % format)
     return format
예제 #23
0
 def _validate(self):
     if not self.testcase_table.is_started():
         raise DataError('File has no test case table.')
예제 #24
0
 def _table_is_allowed(self, table):
     if table is self.testcase_table:
         raise DataError("Resource file '%s' cannot contain tests or "
                         "tasks." % self.source)
     return True
예제 #25
0
 def _validate_var_is_not_scalar_list(self, name, value):
     if is_scalar_var(name) and len(value) > 1:
         raise DataError("Creating a scalar variable with a list value in "
                         "the Variable table is no longer possible. "
                         "Create a list variable '@%s' and use it as a "
                         "scalar variable '%s' instead." % (name[1:], name))
예제 #26
0
 def _validate_mode(self, name1, name2):
     tasks1 = normalize(name1) in ('task', 'tasks')
     tasks2 = normalize(name2) in ('task', 'tasks')
     if tasks1 is not tasks2:
         raise DataError('One file cannot have both tests and tasks.')
예제 #27
0
 def _validate_assign_mark(self, variable):
     if self._seen_assign_mark:
         raise DataError("Assign mark '=' can be used only with the last "
                         "variable.")
     self._seen_assign_mark = variable.endswith('=')
     return variable.rstrip('= ')
예제 #28
0
 def _map_dict_values_to_rounds(self, values, per_round):
     if per_round > 2:
         raise DataError(
             'Number of FOR loop variables must be 1 or 2 when iterating '
             'over dictionaries, got %d.' % per_round)
     return values
예제 #29
0
 def get_library(self, name_or_instance):
     if name_or_instance is None:
         raise DataError("Library can not be None.")
     if is_string(name_or_instance):
         return self._get_lib_by_name(name_or_instance)
     return self._get_lib_by_instance(name_or_instance)
예제 #30
0
 def _table_is_allowed(self, table):
     if table is self.testcase_table:
         raise DataError("Resource file '%s' contains a test case table "
                         "which is not allowed." % self.source)
     return True