diff options
author | Christian Klein <167265+cklein@users.noreply.github.com> | 2023-01-04 22:31:29 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-04 22:31:29 (GMT) |
commit | 7f1eefc6f4843f0fca60308f557a71af11d18a53 (patch) | |
tree | 4e9e176fc5596c5dd2d6d094de2887fe41c77833 /Lib/unittest | |
parent | 52017dbe1681a7cd4fe0e8d6fbbf81fd711a0506 (diff) | |
download | cpython-7f1eefc6f4843f0fca60308f557a71af11d18a53.zip cpython-7f1eefc6f4843f0fca60308f557a71af11d18a53.tar.gz cpython-7f1eefc6f4843f0fca60308f557a71af11d18a53.tar.bz2 |
gh-100739: Respect mock spec when checking for unsafe prefixes (#100740)
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Diffstat (limited to 'Lib/unittest')
-rw-r--r-- | Lib/unittest/mock.py | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/Lib/unittest/mock.py b/Lib/unittest/mock.py index 994947c..47928e5 100644 --- a/Lib/unittest/mock.py +++ b/Lib/unittest/mock.py @@ -652,7 +652,7 @@ class NonCallableMock(Base): raise AttributeError("Mock object has no attribute %r" % name) elif _is_magic(name): raise AttributeError(name) - if not self._mock_unsafe: + if not self._mock_unsafe and (not self._mock_methods or name not in self._mock_methods): if name.startswith(('assert', 'assret', 'asert', 'aseert', 'assrt')): raise AttributeError( f"{name!r} is not a valid assertion. Use a spec " |