Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
Description
Feature or enhancement
Proposal:
Running this:
importunittestfromunittest.mockimportMock,callclassTestCase(unittest.TestCase):deftest_thing(self):mock=Mock()mock.assert_has_calls([call(a=1)])unittest.main()
currently gives this test failure message:
AssertionError: Calls not found.Expected: [call(a=1)]This message does not imply that there were no calls. I propose that the test failure message is instead this:
AssertionError: Calls not found.Expected: [call(a=1)] Actual: []The "Actual" list is already displayed if there are calls. It's only excluded if there are no calls.
The logic that causes an empty list not to be displayed is in the_calls_repr method. For the other usages -assert_called_once_with,assert_called_once, andassert_not_called - the number of calls is displayed directly in the error message so it already says that there are no calls. This makes me think the current behaviour ofassert_has_calls is just an oversight rather than intentional behaviour.
I'd be happy to open a PR for this.
Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
No response