Matchers of dictionaries.
Matches if dictionary contains entries satisfying a dictionary of keys and corresponding value matchers.
Parameters: | matcher_dict – A dictionary mapping keys to associated value matchers, or to expected values for equal_to matching. |
---|
Note that the keys must be actual keys, not matchers. Any value argument that is not a matcher is implicitly wrapped in an equal_to matcher to check for equality.
Examples:
has_entries({'foo':equal_to(1), 'bar':equal_to(2)})
has_entries({'foo':1, 'bar':2})
has_entries also accepts a list of keyword arguments:
Parameters: |
|
---|
Examples:
has_entries(foo=equal_to(1), bar=equal_to(2))
has_entries(foo=1, bar=2)
Finally, has_entries also accepts a list of alternating keys and their value matchers:
Parameters: |
|
---|
Examples:
has_entries('foo', equal_to(1), 'bar', equal_to(2))
has_entries('foo', 1, 'bar', 2)
Matches if dictionary contains key-value entry satisfying a given pair of matchers.
Parameters: |
---|
This matcher iterates the evaluated dictionary, searching for any key-value entry that satisfies key_match and value_match. If a matching entry is found, has_entry is satisfied.
Any argument that is not a matcher is implicitly wrapped in an equal_to matcher to check for equality.
Examples:
has_entry(equal_to('foo'), equal_to(1))
has_entry('foo', 1)
Matches if dictionary contains an entry whose key satisfies a given matcher.
Parameters: | key_match – The matcher to satisfy for the key, or an expected value for equal_to matching. |
---|
This matcher iterates the evaluated dictionary, searching for any key-value entry whose key satisfies the given matcher. If a matching entry is found, has_key is satisfied.
Any argument that is not a matcher is implicitly wrapped in an equal_to matcher to check for equality.
Examples:
has_key(equal_to('foo'))
has_key('foo')
Matches if dictionary contains an entry whose value satisfies a given matcher.
Parameters: | value_match – The matcher to satisfy for the value, or an expected value for equal_to matching. |
---|
This matcher iterates the evaluated dictionary, searching for any key-value entry whose value satisfies the given matcher. If a matching entry is found, has_value is satisfied.
Any argument that is not a matcher is implicitly wrapped in an equal_to matcher to check for equality.
Examples:
has_value(equal_to('bar'))
has_value('bar')