Closed dz0 closed 1 year ago
ps.: I'd expect has_entry
to be as
def has_entry(key, value_match):
return has_entries({key: value_match})
Not quite that simple - has_entry()
allows a matcher for the key as well as for the value. I'll take a look when I have some time.
Thinking about it, perhaps that's why has_entry()
doesn't give better mismatch messages. Imagine that the key was specified as hamcrest.anything()
- how should the message read then?
Still, if the key matched exactly once, we could probably give better messages in that special but common case.
Does https://github.com/hamcrest/PyHamcrest/pull/157 look any good, @dz0 and @offbyone?
This fix has been merged & released.
Hi, simple example
Why
has_entry
does not display (block) deeper cause?:Expected: a dictionary containing {'level2': <42>} but: value for 'level2' was <2>
Expected: a dictionary containing {'level1': a dictionary containing {'level2': <42>}} but: value for 'level1' value for 'level2' was <2>