aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/tools/python3/Lib/unittest/mock.py
diff options
context:
space:
mode:
authorshadchin <shadchin@yandex-team.com>2024-10-27 10:52:33 +0300
committershadchin <shadchin@yandex-team.com>2024-10-27 11:03:47 +0300
commit1529383373617c6d14ad4972afdc46a5eb35f954 (patch)
tree229b7647fafadd4ee4b93d20e606c534ad697365 /contrib/tools/python3/Lib/unittest/mock.py
parent41d598c624442bf6918407466dac3316b8277347 (diff)
downloadydb-1529383373617c6d14ad4972afdc46a5eb35f954.tar.gz
Update Python 3 to 3.12.7
commit_hash:052a122399d67f1ea5dfbc5f6457e3e06200becf
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 9398f56506b..3e9791b22dc 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):