You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, the MatchesDict matcher simply crashes when matching against a value that is not a dictionary:
>>> assert_that(None, MatchesDict({1: Equals(2)}))
TypeError: 'NoneType' object is not iterable
>>> assert_that([], MatchesDict({}))
AttributeError: 'list' object has no attribute 'keys'
This makes it unnecessarily hard to diagnose tests that fail because an expected dictionary was not actually a dictionary, especially when using nested compound matchers against structures.
Would it make sense to add a check to make MatchesDict raise a MismatchError for non-dictionary-like values, instead?
The text was updated successfully, but these errors were encountered:
Currently, the
MatchesDict
matcher simply crashes when matching against a value that is not a dictionary:This makes it unnecessarily hard to diagnose tests that fail because an expected dictionary was not actually a dictionary, especially when using nested compound matchers against structures.
Would it make sense to add a check to make
MatchesDict
raise aMismatchError
for non-dictionary-like values, instead?The text was updated successfully, but these errors were encountered: