⬅︎ Back to Careful with your assertRaises() and inheritance of exceptions
I'm not surprised by this behavior, but sometimes you do want to check the exact error class. When I changed a function in PyMongo to raise a different error in the same hiearchy, I wrote assertRaisesExactly as an alternative to assertRaises:https://github.com/mongodb/mongo-python-driver/blob/master/test/utils.py#L62
Thank you! Clearly I'm not alone in being anal about testing *exactly* which exception is raised.
Comment
I'm not surprised by this behavior, but sometimes you do want to check the exact error class. When I changed a function in PyMongo to raise a different error in the same hiearchy, I wrote assertRaisesExactly as an alternative to assertRaises:
https://github.com/mongodb/mongo-python-driver/blob/master/test/utils.py#L62
Replies
Thank you! Clearly I'm not alone in being anal about testing *exactly* which exception is raised.