diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2017-01-06 18:16:07 +0100 |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2017-01-06 18:16:07 +0100 |
commit | 730de3af8b5503cee1660fbb57568af4a20dfafe (patch) | |
tree | da1c5952deae5e81fc073d6783ca6e468ecef979 /Lib/unittest | |
parent | 4b5a4553c7513a3de9891cf3634fcc1dcd8f1175 (diff) | |
parent | 1a5eab5707569b3b8fe59306d59724197e3d84a0 (diff) | |
download | cpython-730de3af8b5503cee1660fbb57568af4a20dfafe.tar.gz |
Merge 3.6
Diffstat (limited to 'Lib/unittest')
-rw-r--r-- | Lib/unittest/mock.py | 26 |
1 files changed, 8 insertions, 18 deletions
diff --git a/Lib/unittest/mock.py b/Lib/unittest/mock.py index dcac5a2925..dbb05d780e 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): |