summaryrefslogtreecommitdiff
path: root/Lib/unittest/mock.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2017-01-25 13:27:44 +0200
committerSerhiy Storchaka <storchaka@gmail.com>2017-01-25 13:27:44 +0200
commit19b1c3b04e2b01bd3b35b9e14c1735959d3b65e8 (patch)
tree24ab2ab26f886e3da21f91979512412360abea5d /Lib/unittest/mock.py
parent3f19a274c28567afb39ba46ea8a2ebdeab816b0b (diff)
parent82e2d87e841850bc39db8ae954321986761492f5 (diff)
downloadcpython-19b1c3b04e2b01bd3b35b9e14c1735959d3b65e8.tar.gz
Issue #27867: Function PySlice_GetIndicesEx() is deprecated and replaced with
a macro if Py_LIMITED_API is not set or set to the value between 0x03050400 and 0x03060000 (not including) or 0x03060100 or higher. Added functions PySlice_Unpack() and PySlice_AdjustIndices().
Diffstat (limited to 'Lib/unittest/mock.py')
-rw-r--r--Lib/unittest/mock.py32
1 files changed, 14 insertions, 18 deletions
diff --git a/Lib/unittest/mock.py b/Lib/unittest/mock.py
index b6b3836234..315b61157b 100644
--- a/Lib/unittest/mock.py
+++ b/Lib/unittest/mock.py
@@ -104,26 +104,16 @@ def _check_signature(func, mock, skipfirst, instance=False):
def _copy_func_details(func, funcopy):
- funcopy.__name__ = func.__name__
- funcopy.__doc__ = func.__doc__
- try:
- funcopy.__text_signature__ = func.__text_signature__
- except AttributeError:
- pass
# we explicitly don't copy func.__dict__ into this copy as it would
# expose original attributes that should be mocked
- try:
- funcopy.__module__ = func.__module__
- except AttributeError:
- pass
- try:
- funcopy.__defaults__ = func.__defaults__
- except AttributeError:
- pass
- try:
- funcopy.__kwdefaults__ = func.__kwdefaults__
- except AttributeError:
- pass
+ for attribute in (
+ '__name__', '__doc__', '__text_signature__',
+ '__module__', '__defaults__', '__kwdefaults__',
+ ):
+ try:
+ setattr(funcopy, attribute, getattr(func, attribute))
+ except AttributeError:
+ pass
def _callable(obj):
@@ -248,6 +238,9 @@ class _SentinelObject(object):
def __repr__(self):
return 'sentinel.%s' % self.name
+ def __reduce__(self):
+ return 'sentinel.%s' % self.name
+
class _Sentinel(object):
"""Access attributes to return a named object, usable as a sentinel."""
@@ -260,6 +253,9 @@ class _Sentinel(object):
raise AttributeError
return self._sentinels.setdefault(name, _SentinelObject(name))
+ def __reduce__(self):
+ return 'sentinel'
+
sentinel = _Sentinel()