]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-119600: mock: do not access attributes of original when new_callable is set (...
authorRobert Collins <robert.collins@cognite.com>
Tue, 11 Jun 2024 05:41:12 +0000 (07:41 +0200)
committerGitHub <noreply@github.com>
Tue, 11 Jun 2024 05:41:12 +0000 (06:41 +0100)
commit422c4fc855afd18bcc6415902ea1d85a50cb7ce1
tree78d95472f838196f72aa5d58c97bdfc188a67db1
parent6efe3460693c4f39de198a64cebeeee8b1d4e8b6
gh-119600: mock: do not access attributes of original when new_callable is set (#119601)

In order to patch flask.g e.g. as in #84982, that
proxies getattr must not be invoked. For that,
mock must not try to read from the original
object. In some cases that is unavoidable, e.g.
when doing autospec. However, patch("flask.g",
new_callable=MagicMock) should be entirely safe.
Lib/test/test_unittest/testmock/support.py
Lib/test/test_unittest/testmock/testpatch.py
Lib/unittest/mock.py
Misc/NEWS.d/next/Library/2024-06-10-14-00-40.gh-issue-119600.jJMf4C.rst [new file with mode: 0644]