def convert_type_list_to_dict(self, types):
     names = self._argspec.argument_names
     if len(types) > len(names):
         raise DataError('Type information given to %d argument%s but '
                         'keyword has only %d argument%s.'
                         % (len(types), s(types), len(names), s(names)))
     return {name: value for name, value in zip(names, types) if value}
Exemplo n.º 2
0
 def _replace_variables(self, data):
     values = super(ForInZipRunner, self)._replace_variables(data)
     if len(data.variables) == len(data.values):
         return values
     raise DataError('FOR IN ZIP expects an equal number of variables and '
                     'iterables. Got %d variable%s and %d iterable%s.'
                     % (len(data.variables), s(data.variables),
                        len(data.values), s(data.values)))
Exemplo n.º 3
0
 def _replace_variables(self, data):
     values = self._context.variables.replace_list(data.values)
     if data.range:
         values = self._get_range_items(values)
     if len(values) % len(data.variables) == 0:
         return values
     raise DataError('Number of FOR loop values should be multiple of '
                     'variables. Got %d variables but %d value%s.'
                     % (len(data.variables), len(values), s(values)))
Exemplo n.º 4
0
 def validate_type_dict(self, types):
     # 'return' isn't used for anything yet but it may be shown by Libdoc
     # in the future. Trying to be forward compatible.
     names = set(self._argspec.argument_names + ['return'])
     extra = [t for t in types if t not in names]
     if extra:
         raise DataError('Type information given to non-existing '
                         'argument%s %s.'
                         % (s(extra), seq2str(sorted(extra))))
     return types
    def get_element_count(self, source, xpath='.'):
        """Returns and logs how many elements the given `xpath` matches.

        Arguments `source` and `xpath` have exactly the same semantics as with
        `Get Elements` keyword that this keyword uses internally.

        See also `Element Should Exist` and `Element Should Not Exist`.

        New in Robot Framework 2.7.5.
        """
        count = len(self.get_elements(source, xpath))
        logger.info("%d element%s matched '%s'." % (count, s(count), xpath))
        return count
Exemplo n.º 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 variable%s but %d value%s.'
                     % (variables, s(variables), values, s(values)))
Exemplo n.º 7
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)))
Exemplo n.º 8
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))
     )
Exemplo n.º 9
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)))