]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
bpo-41877 Check for asert, aseert, assrt in mocks (GH-23165)
authorvabr-g <vabr@google.com>
Thu, 5 Nov 2020 17:04:38 +0000 (18:04 +0100)
committerGitHub <noreply@github.com>
Thu, 5 Nov 2020 17:04:38 +0000 (09:04 -0800)
commit4662fa9bfe4a849fe87bfb321d8ef0956c89a772
tree82067c4fbc0e0d76413b2fc8de1f73c777c82efa
parent133aa2d5816b69d8ee755e1a9d2d1977b9205736
bpo-41877 Check for asert, aseert, assrt in mocks (GH-23165)

Currently, a Mock object which is not unsafe will raise an
AttributeError if an attribute with the prefix assert or assret is
accessed on it. This protects against misspellings of real assert
method calls, which lead to tests passing silently even if the tested
code does not satisfy the intended assertion.

Recently a check was done in a large code base (Google) and three
more frequent ways of misspelling assert were found causing harm:
asert, aseert, assrt. These are now added to the existing check.
Lib/unittest/mock.py
Lib/unittest/test/testmock/testmock.py
Misc/NEWS.d/next/Library/2020-11-05-16-00-03.bpo-41877.FHbngM.rst [new file with mode: 0644]