]> granicus.if.org Git - python/commit
bpo-37828: Fix default mock_name in unittest.mock.assert_called error (GH-16166)
authorAbraham Toriz Cruz <awonderfulcode@gmail.com>
Tue, 17 Sep 2019 11:16:08 +0000 (06:16 -0500)
committerPablo Galindo <Pablogsal@gmail.com>
Tue, 17 Sep 2019 11:16:08 +0000 (12:16 +0100)
commit5f5f11faf9de0d8dcbe1a8a4eb35d2a4232d6eaa
tree18cdf4ee14ec18b596aa1ea5f6fb4ad60bccc508
parent219fb9d65ef7e5363eccc9dde0988bb085db1c86
bpo-37828: Fix default mock_name in unittest.mock.assert_called error (GH-16166)

In the format string for assert_called the evaluation order is incorrect and hence for mock's without name, 'None' is printed whereas it should be 'mock' like for other messages. The error message is ("Expected '%s' to have been called." % self._mock_name or 'mock').
Lib/unittest/mock.py
Lib/unittest/test/testmock/testmock.py
Misc/NEWS.d/next/Library/2019-09-15-21-31-18.bpo-37828.gLLDX7.rst [new file with mode: 0644]