Matchers that perform text comparisons.
Matches if object is a string containing a given string.
Parameters: | string – The string to search for. |
---|
This matcher first checks whether the evaluated object is a string. If so, it checks whether it contains string.
Example:
contains_string("def")
will match “abcdefg”.
Matches if object is a string ending with a given string.
Parameters: | string – The string to search for. |
---|
This matcher first checks whether the evaluated object is a string. If so, it checks if string matches the ending characters of the evaluated object.
Example:
ends_with("bar")
will match “foobar”.
Matches if object is a string equal to a given string, ignoring case differences.
Parameters: | string – The string to compare against as the expected value. |
---|
This matcher first checks whether the evaluated object is a string. If so, it compares it with string, ignoring differences of case.
Example:
equal_to_ignoring_case("hello world")
will match “heLLo WorlD”.
Matches if object is a string equal to a given string, ignoring differences in whitespace.
Parameters: | string – The string to compare against as the expected value. |
---|
This matcher first checks whether the evaluated object is a string. If so, it compares it with string, ignoring differences in runs of whitespace.
Example:
equal_to_ignoring_whitespace("hello world")
will match "hello world".
Matches if object is a string containing a match for a given regular expression.
Parameters: | pattern – The regular expression to search for. |
---|
This matcher first checks whether the evaluated object is a string. If so, it checks if the regular expression pattern matches anywhere within the evaluated object.
Matches if object is a string starting with a given string.
Parameters: | string – The string to search for. |
---|
This matcher first checks whether the evaluated object is a string. If so, it checks if string matches the beginning characters of the evaluated object.
Example:
starts_with("foo")
will match “foobar”.
Matches if object is a string containing a given list of substrings in relative order.
Parameters: | string1,... – A comma-separated list of strings. |
---|
This matcher first checks whether the evaluated object is a string. If so, it checks whether it contains a given list of strings, in relative order to each other. The searches are performed starting from the beginning of the evaluated string.
Example:
string_contains_in_order("bc", "fg", "jkl")
will match “abcdefghijklm”.