]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
[3.7] bpo-36871: Handle spec errors in assert_has_calls (GH-16364) (GH-16374)
authorGregory P. Smith <greg@krypto.org>
Wed, 25 Sep 2019 05:29:17 +0000 (22:29 -0700)
committerGitHub <noreply@github.com>
Wed, 25 Sep 2019 05:29:17 +0000 (22:29 -0700)
commit4042e1afd252858de53e2b79d946a51a0182d1ba
tree361a74856d7a8dd4e206b6c33b6f4be124d9d92f
parent16c0f6df62a39f9f7712b1c0577de4eefcb4c1bf
[3.7] bpo-36871: Handle spec errors in assert_has_calls (GH-16364) (GH-16374)

Handle spec errors in assert_has_calls (GH-16005) (GH-16364)

The fix in PR 13261 handled the underlying issue about the spec for specific methods not being applied correctly, but it didn't fix the issue that was causing the misleading error message.

The code currently grabs a list of responses from _call_matcher (which may include exceptions). But it doesn't reach inside the list when checking if the result is an exception. This results in a misleading error message when one of the provided calls does not match the spec.

https://bugs.python.org/issue36871

Co-authored-by: Samuel Freilich <sfreilich@google.com>
(cherry picked from commit 1a17a054f6314ce29cd2632c28aeed317a615360)
Lib/unittest/mock.py
Lib/unittest/test/testmock/testmock.py
Misc/NEWS.d/next/Core and Builtins/2019-09-24-18-45-46.bpo-36871.p47knk.rst [new file with mode: 0644]