-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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
Better error messages in unittest.mock #79228
Comments
When developing unit tests with
It would be really helpful if those 3 calls were listed in the assertion error. I am happy to add this if people agree it is a good thing. |
It seems to be a good idea. If you attach a sample, it would be great. |
Sure, consider the following code: from unittest import mock
m = mock.Mock()
m(1, 3)
m("Test", data=[42]) When I call m.assert_not_called() I get the following error message: AssertionError: Expected 'mock' to not have been called. Called 2 times. This is what I would like to improve. On the other hand, if I call m.assert_has_calls(mock.call(3)) I get the following error: AssertionError: Calls not found. This is great and may serve as a template for what I want to introduce. |
(The example above should have been "m.assert_has_calls([mock.call(3)])" but it does not affect my point.) |
I think that is a good change. Maybe you can apply the change on 3.6, 3.7 and 3.8 |
Thanks Petter Strandmark! |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: