Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MatchesDict crashes ungracefully non-dictionary values #267

Open
PiDelport opened this issue Jan 11, 2018 · 0 comments
Open

MatchesDict crashes ungracefully non-dictionary values #267

PiDelport opened this issue Jan 11, 2018 · 0 comments

Comments

@PiDelport
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant