]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-100690: Raise an AttributeError when the assert_ prefix is forgotten when using...
authorChristian Klein <167265+cklein@users.noreply.github.com>
Fri, 6 Jan 2023 18:38:50 +0000 (19:38 +0100)
committerGitHub <noreply@github.com>
Fri, 6 Jan 2023 18:38:50 +0000 (18:38 +0000)
commit1d4d677d1c90fcf4886ded0bf04b8f9d5b60b909
tree3fc895376703b2960e4e7776a21868d9fdaba4b4
parent9ffbc58f5cb6d2b002f8785886588d646af517db
gh-100690: Raise an AttributeError when the assert_ prefix is forgotten when using Mock (#100691)

Mock objects which are not unsafe will now raise an AttributeError when accessing an
attribute that matches the name of an assertion but without the prefix `assert_`, e.g. accessing `called_once` instead of `assert_called_once`.

This is in addition to this already happening for accessing attributes with prefixes assert, assret, asert, aseert, and assrt.
Lib/test/test_unittest/testmock/testmock.py
Lib/unittest/mock.py
Misc/NEWS.d/next/Library/2023-01-02-16-59-49.gh-issue-100690.2EgWPS.rst [new file with mode: 0644]