def list_should_not_contain_value(self, list_, value, msg=None):
        """Fails if the ``value`` is not found from ``list``.

        See `List Should Contain Value` for an explanation of ``msg``.
        """
        default = "%s contains value '%s'." % (seq2str2(list_), value)
        _verify_condition(value not in list_, default, msg)
Example #2
0
    def list_should_not_contain_value(self, list_, value, msg=None):
        """Fails if the ``value`` is not found from ``list``.

        See `List Should Contain Value` for an explanation of ``msg``.
        """
        default = "%s contains value '%s'." % (seq2str2(list_), value)
        _verify_condition(value not in list_, default, msg)
Example #3
0
    def list_should_not_contain_value(self, list_, value, msg=None):
        """Fails if the ``value`` is found from ``list``.

        Use the ``msg`` argument to override the default error message.
        """
        self._validate_list(list_)
        default = "%s contains value '%s'." % (seq2str2(list_), value)
        _verify_condition(value not in list_, default, msg)
Example #4
0
    def list_should_contain_value(self, list_, value, msg=None):
        """Fails if the ``value`` is not found from ``list``.

        If the keyword fails, the default error messages is ``<list> does
        not contain value '<value>'``. A custom message can be given using
        the ``msg`` argument.
        """
        default = "%s does not contain value '%s'." % (seq2str2(list_), value)
        _verify_condition(value in list_, default, msg)
 def _log_imported_library(self, name, args, lib):
     type = lib.__class__.__name__.replace('Library', '').lower()[1:]
     listener = ', with listener' if lib.has_listener else ''
     LOGGER.info("Imported library '%s' with arguments %s "
                 "(version %s, %s type, %s scope, %d keywords%s)"
                 % (name, seq2str2(args), lib.version or '<unknown>',
                    type, lib.scope.lower(), len(lib), listener))
     if not lib and not lib.has_listener:
         LOGGER.warn("Imported library '%s' contains no keywords" % name)
    def list_should_contain_value(self, list_, value, msg=None):
        """Fails if the ``value`` is not found from ``list``.

        If the keyword fails, the default error messages is ``<list> does
        not contain value '<value>'``. A custom message can be given using
        the ``msg`` argument.
        """
        default = "%s does not contain value '%s'." % (seq2str2(list_), value)
        _verify_condition(value in list_, default, msg)
Example #7
0
 def _log_imported_library(self, name, args, lib):
     type = lib.__class__.__name__.replace("Library", "").lower()[1:]
     listener = ", with listener" if lib.has_listener else ""
     LOGGER.info(
         "Imported library '%s' with arguments %s "
         "(version %s, %s type, %s scope, %d keywords%s)"
         % (name, seq2str2(args), lib.version or "<unknown>", type, lib.scope.lower(), len(lib), listener)
     )
     if not lib and not lib.has_listener:
         LOGGER.warn("Imported library '%s' contains no keywords" % name)
Example #8
0
 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 _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 _import_library(self, name, positional, named, lib):
     args = positional + ['%s=%s' % arg for arg in sorted(named.items())]
     key = (name, positional, named)
     if key in self._library_cache:
         LOGGER.info("Found test library '%s' with arguments %s from cache"
                     % (name, seq2str2(args)))
         return self._library_cache[key]
     lib.create_handlers()
     self._library_cache[key] = lib
     self._log_imported_library(name, args, lib)
     return lib
    def should_contain_match(self,
                             list,
                             pattern,
                             msg=None,
                             case_insensitive=False,
                             whitespace_insensitive=False):
        """Fails if ``pattern`` is not found in ``list``.

        See `List Should Contain Value` for an explanation of ``msg``.

        By default, pattern matching is similar to matching files in a shell
        and is case-sensitive and whitespace-sensitive. In the pattern syntax,
        ``*`` matches to anything and ``?`` matches to any single character. You
        can also prepend ``glob=`` to your pattern to explicitly use this pattern
        matching behavior.

        If you prepend ``regexp=`` to your pattern, your pattern will be used
        according to the Python
        [http://docs.python.org/2/library/re.html|re module] regular expression
        syntax. Important note: Backslashes are an escape character, and must
        be escaped with another backslash (e.g. ``regexp=\\\\d{6}`` to search for
        ``\\d{6}``). See `BuiltIn.Should Match Regexp` for more details.

        If ``case_insensitive`` is given a true value (see `Boolean arguments`),
        the pattern matching will ignore case.

        If ``whitespace_insensitive`` is given a true value (see `Boolean
        arguments`), the pattern matching will ignore whitespace.

        Non-string values in lists are ignored when matching patterns.

        The given list is never altered by this keyword.

        See also ``Should Not Contain Match``.

        Examples:
        | Should Contain Match | ${list} | a*              | | | # Match strings beginning with 'a'. |
        | Should Contain Match | ${list} | regexp=a.*      | | | # Same as the above but with regexp. |
        | Should Contain Match | ${list} | regexp=\\\\d{6} | | | # Match strings containing six digits. |
        | Should Contain Match | ${list} | a*  | case_insensitive=True       | | # Match strings beginning with 'a' or 'A'. |
        | Should Contain Match | ${list} | ab* | whitespace_insensitive=yes  | | # Match strings beginning with 'ab' with possible whitespace ignored. |
        | Should Contain Match | ${list} | ab* | whitespace_insensitive=true | case_insensitive=true | # Same as the above but also ignore case. |

        New in Robot Framework 2.8.6.
        """
        matches = _get_matches_in_iterable(list, pattern, case_insensitive,
                                           whitespace_insensitive)
        default = "%s does not contain match for pattern '%s'." \
                  % (seq2str2(list), pattern)
        _verify_condition(matches, default, msg)
Example #12
0
    def should_not_contain_match(self, list, pattern, msg=None,
                                 case_insensitive=False,
                                 whitespace_insensitive=False):
        """Fails if ``pattern`` is found in ``list``.

        Exact opposite of `Should Contain Match` keyword. See that keyword
        for information about arguments and usage in general.
        """
        _List._validate_list(self, list)
        matches = _get_matches_in_iterable(list, pattern, case_insensitive,
                                           whitespace_insensitive)
        default = "%s contains match for pattern '%s'." \
                  % (seq2str2(list), pattern)
        _verify_condition(not matches, default, msg)
Example #13
0
 def _import_if_needed(self, path_or_variables, args=None):
     if not is_string(path_or_variables):
         return path_or_variables
     LOGGER.info("Importing variable file '%s' with args %s"
                 % (path_or_variables, args))
     if path_or_variables.lower().endswith('.yaml'):
         importer = YamlImporter()
     else:
         importer = PythonImporter()
     try:
         return importer.import_variables(path_or_variables, args)
     except:
         args = 'with arguments %s ' % seq2str2(args) if args else ''
         raise DataError("Processing variable file '%s' %sfailed: %s"
                         % (path_or_variables, args, get_error_message()))
Example #14
0
 def _import_if_needed(self, path_or_variables, args=None):
     if not is_string(path_or_variables):
         return path_or_variables
     LOGGER.info("Importing variable file '%s' with args %s" %
                 (path_or_variables, args))
     if path_or_variables.lower().endswith('.yaml'):
         importer = YamlImporter()
     else:
         importer = PythonImporter()
     try:
         return importer.import_variables(path_or_variables, args)
     except:
         args = 'with arguments %s ' % seq2str2(args) if args else ''
         raise DataError("Processing variable file '%s' %sfailed: %s" %
                         (path_or_variables, args, get_error_message()))
Example #15
0
 def _import_variables(self, import_setting, overwrite=False):
     path = self._resolve_name(import_setting)
     args = self._resolve_args(import_setting)
     if overwrite or (path, args) not in self._imported_variable_files:
         self._imported_variable_files.add((path, args))
         self.variables.set_from_file(path, args, overwrite)
         LOGGER.imported("Variables", os.path.basename(path),
                         args=list(args),
                         importer=import_setting.source,
                         source=path)
     else:
         msg = "Variable file '%s'" % path
         if args:
             msg += " with arguments %s" % seq2str2(args)
         LOGGER.info("%s already imported by suite '%s'"
                     % (msg, self._suite_name))
Example #16
0
    def should_contain_match(self, list, pattern, msg=None,
                             case_insensitive=False,
                             whitespace_insensitive=False):
        """Fails if ``pattern`` is not found in ``list``.

        See `List Should Contain Value` for an explanation of ``msg``.

        By default, pattern matching is similar to matching files in a shell
        and is case-sensitive and whitespace-sensitive. In the pattern syntax,
        ``*`` matches to anything and ``?`` matches to any single character. You
        can also prepend ``glob=`` to your pattern to explicitly use this pattern
        matching behavior.

        If you prepend ``regexp=`` to your pattern, your pattern will be used
        according to the Python
        [http://docs.python.org/2/library/re.html|re module] regular expression
        syntax. Important note: Backslashes are an escape character, and must
        be escaped with another backslash (e.g. ``regexp=\\\\d{6}`` to search for
        ``\\d{6}``). See `BuiltIn.Should Match Regexp` for more details.

        If ``case_insensitive`` is given a true value (see `Boolean arguments`),
        the pattern matching will ignore case.

        If ``whitespace_insensitive`` is given a true value (see `Boolean
        arguments`), the pattern matching will ignore whitespace.

        Non-string values in lists are ignored when matching patterns.

        The given list is never altered by this keyword.

        See also ``Should Not Contain Match``.

        Examples:
        | Should Contain Match | ${list} | a*              | | | # Match strings beginning with 'a'. |
        | Should Contain Match | ${list} | regexp=a.*      | | | # Same as the above but with regexp. |
        | Should Contain Match | ${list} | regexp=\\\\d{6} | | | # Match strings containing six digits. |
        | Should Contain Match | ${list} | a*  | case_insensitive=True       | | # Match strings beginning with 'a' or 'A'. |
        | Should Contain Match | ${list} | ab* | whitespace_insensitive=yes  | | # Match strings beginning with 'ab' with possible whitespace ignored. |
        | Should Contain Match | ${list} | ab* | whitespace_insensitive=true | case_insensitive=true | # Same as the above but also ignore case. |

        New in Robot Framework 2.8.6.
        """
        matches = _get_matches_in_iterable(list, pattern, case_insensitive,
                                           whitespace_insensitive)
        default = "%s does not contain match for pattern '%s'." \
                  % (seq2str2(list), pattern)
        _verify_condition(matches, default, msg)
Example #17
0
    def should_not_contain_match(self,
                                 list,
                                 pattern,
                                 msg=None,
                                 case_insensitive=False,
                                 whitespace_insensitive=False):
        """Fails if ``pattern`` is found in ``list``.

        Exact opposite of `Should Contain Match` keyword. See that keyword
        for information about arguments and usage in general.
        """
        _List._validate_list(self, list)
        matches = _get_matches_in_iterable(list, pattern, case_insensitive,
                                           whitespace_insensitive)
        default = "%s contains match for pattern '%s'." \
                  % (seq2str2(list), pattern)
        _verify_condition(not matches, default, msg)
Example #18
0
 def _import_variables(self, import_setting, overwrite=False):
     path = self._resolve_name(import_setting)
     args = self._resolve_args(import_setting)
     if overwrite or (path, args) not in self._imported_variable_files:
         self._imported_variable_files.add((path, args))
         self.variables.set_from_file(path, args, overwrite)
         LOGGER.imported("Variables",
                         os.path.basename(path),
                         args=list(args),
                         importer=import_setting.source,
                         source=path)
     else:
         msg = "Variable file '%s'" % path
         if args:
             msg += " with arguments %s" % seq2str2(args)
         LOGGER.info("%s already imported by suite '%s'" %
                     (msg, self.suite.longname))
 def _start(self, type_, name, args=''):
     args = ' ' + utils.seq2str2(args)
     self._write('+%s START %s: %s%s' % ('-'*self._indent, type_, name, args))
     self._indent += 1
Example #20
0
 def _import_library(self, name, positional, named, lib):
     args = positional + ["%s=%s" % arg for arg in sorted(named.items())]
     key = (name, positional, named)
     if key in self._library_cache:
         LOGGER.info("Found test library '%s' with arguments %s from cache" % (name, seq2str2(args)))
         return self._library_cache[key]
     lib.create_handlers()
     self._library_cache[key] = lib
     self._log_imported_library(name, args, lib)
     return lib
Example #21
0
 def _get_for_loop(self, kw):
     joiner = ' %s ' % kw.flavor
     return ', '.join(kw.variables) + joiner + seq2str2(kw.values)
Example #22
0
 def _get_for_loop(self, kw):
     joiner = " %s " % kw.flavor
     return ", ".join(kw.variables) + joiner + seq2str2(kw.values)
 def _get_for_loop(self, kw):
     joiner = ' %s ' % kw.flavor
     return ', '.join(kw.variables) + joiner + seq2str2(kw.values)
Example #24
0
 def _start(self, type_, name, args=''):
     args = ' ' + seq2str2(args)
     self._write('+%s START %s: %s%s' % ('-'*self._indent, type_, name, args))
     self._indent += 1