robotframework--Collections库的API介绍

2021-06-17 03:05

阅读:736

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 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.


评论


亲,登录后才可以留言!