summaryrefslogtreecommitdiff
path: root/Lib/unittest/mock.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/unittest/mock.py')
-rw-r--r--Lib/unittest/mock.py17
1 files changed, 4 insertions, 13 deletions
diff --git a/Lib/unittest/mock.py b/Lib/unittest/mock.py
index 37ea5c7e45..9e692981a2 100644
--- a/Lib/unittest/mock.py
+++ b/Lib/unittest/mock.py
@@ -1042,8 +1042,7 @@ class _AnyComparer(list):
the left."""
def __contains__(self, item):
for _call in self:
- if len(item) != len(_call):
- continue
+ assert len(item) == len(_call)
if all([
expected == actual
for expected, actual in zip(item, _call)
@@ -1856,7 +1855,8 @@ class _patch_dict(object):
def __exit__(self, *args):
"""Unpatch the dict."""
- self._unpatch_dict()
+ if self._original is not None:
+ self._unpatch_dict()
return False
@@ -2168,7 +2168,7 @@ class AsyncMockMixin(Base):
self.__dict__['__code__'] = code_mock
async def _execute_mock_call(self, /, *args, **kwargs):
- # This is nearly just like super(), except for sepcial handling
+ # This is nearly just like super(), except for special handling
# of coroutines
_call = self.call_args
@@ -2541,12 +2541,6 @@ class _Call(tuple):
return tuple.__getattribute__(self, attr)
- def count(self, /, *args, **kwargs):
- return self.__getattr__('count')(*args, **kwargs)
-
- def index(self, /, *args, **kwargs):
- return self.__getattr__('index')(*args, **kwargs)
-
def _get_call_arguments(self):
if len(self) == 2:
args, kwargs = self
@@ -2917,9 +2911,6 @@ class _AsyncIterator:
code_mock.co_flags = inspect.CO_ITERABLE_COROUTINE
self.__dict__['__code__'] = code_mock
- def __aiter__(self):
- return self
-
async def __anext__(self):
try:
return next(self.iterator)