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

raises matcher Mismatch text could be more helpful #215

Open
thomir opened this issue Feb 17, 2016 · 2 comments
Open

raises matcher Mismatch text could be more helpful #215

thomir opened this issue Feb 17, 2016 · 2 comments

Comments

@thomir
Copy link
Member

thomir commented Feb 17, 2016

I often write test code like so:

self.assertThat(
    lambda: client.add_key_for_owner(user_two, fingerprint),
    raises(GPGServiceException("Fingerprint already in the database.")))

However, if there's a bug in my code and the function in question raises a different exception, I get the following output:

MismatchError: <type 'exceptions.NameError'> is not a <class 'lp.services.gpg.interfaces.GPGServiceException'>

At this point I usually change the test to run the function outside of an assertion so I get a proper traceback that allows me to debug the problem. It would be nice if the raises matcher gave me more verbose information about what was raised - at a minimum str(exception).

@jml
Copy link
Member

jml commented Feb 18, 2016

Yeah, I agree that this would be a better behaviour. ISTR @rbtcollins suggesting that the current behaviour is a feature, not a bug. Rob, want to chime in?

@mithrandi
Copy link

I can't think of any situation where I would want to only see the type of the incorrect exception.

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

3 participants