summaryrefslogtreecommitdiffstats
path: root/Lib/unittest
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/unittest')
-rw-r--r--Lib/unittest/mock.py2
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 "