mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
gh-100739: Respect mock spec when checking for unsafe prefixes (#100740)
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
This commit is contained in:
parent
52017dbe16
commit
7f1eefc6f4
3 changed files with 18 additions and 1 deletions
|
@ -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 "
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue