aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/tools/python3/Lib/unittest/mock.py
diff options
context:
space:
mode:
authorAlexander Smirnov <alex@ydb.tech>2024-10-28 20:34:11 +0000
committerAlexander Smirnov <alex@ydb.tech>2024-10-28 20:34:11 +0000
commitef9875b11a33dbd25e92bc6b4cf692c18c9ba0ce (patch)
tree1f2fd4e4d9e585da35937b42fbda5f854af04728 /contrib/tools/python3/Lib/unittest/mock.py
parent37ae9cc90160b53eb0e22021c47b3996a01cd656 (diff)
parente3c8507a3d1cb090278f211232ddfde3bedc54d4 (diff)
downloadydb-ef9875b11a33dbd25e92bc6b4cf692c18c9ba0ce.tar.gz
Merge branch 'rightlib' into mergelibs-241028-2033
Diffstat (limited to 'contrib/tools/python3/Lib/unittest/mock.py')
-rw-r--r--contrib/tools/python3/Lib/unittest/mock.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/contrib/tools/python3/Lib/unittest/mock.py b/contrib/tools/python3/Lib/unittest/mock.py
index 9398f56506..3e9791b22d 100644
--- a/contrib/tools/python3/Lib/unittest/mock.py
+++ b/contrib/tools/python3/Lib/unittest/mock.py
@@ -598,7 +598,9 @@ class NonCallableMock(Base):
side_effect = property(__get_side_effect, __set_side_effect)
- def reset_mock(self, visited=None,*, return_value=False, side_effect=False):
+ def reset_mock(self, visited=None, *,
+ return_value: bool = False,
+ side_effect: bool = False):
"Restore the mock object to its initial state."
if visited is None:
visited = []
@@ -2189,6 +2191,17 @@ class MagicMock(MagicMixin, Mock):
self._mock_add_spec(spec, spec_set)
self._mock_set_magics()
+ def reset_mock(self, /, *args, return_value: bool = False, **kwargs):
+ if (
+ return_value
+ and self._mock_name
+ and _is_magic(self._mock_name)
+ ):
+ # Don't reset return values for magic methods,
+ # otherwise `m.__str__` will start
+ # to return `MagicMock` instances, instead of `str` instances.
+ return_value = False
+ super().reset_mock(*args, return_value=return_value, **kwargs)
class MagicProxy(Base):