diff options
author | Larry Hastings <larry@hastings.org> | 2014-01-24 14:17:25 (GMT) |
---|---|---|
committer | Larry Hastings <larry@hastings.org> | 2014-01-24 14:17:25 (GMT) |
commit | 5c66189e88034ba807b10422a8750b0c71c4b62b (patch) | |
tree | 541626d6d627396acaccab565e936d35c3b99173 /Lib/unittest | |
parent | b3c0f4067d992fc2c0d8578e308cc7167dc98f32 (diff) | |
download | cpython-5c66189e88034ba807b10422a8750b0c71c4b62b.zip cpython-5c66189e88034ba807b10422a8750b0c71c4b62b.tar.gz cpython-5c66189e88034ba807b10422a8750b0c71c4b62b.tar.bz2 |
Issue #20189: Four additional builtin types (PyTypeObject,
PyMethodDescr_Type, _PyMethodWrapper_Type, and PyWrapperDescr_Type)
have been modified to provide introspection information for builtins.
Also: many additional Lib, test suite, and Argument Clinic fixes.
Diffstat (limited to 'Lib/unittest')
-rw-r--r-- | Lib/unittest/mock.py | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/Lib/unittest/mock.py b/Lib/unittest/mock.py index dc5c033..8b76503 100644 --- a/Lib/unittest/mock.py +++ b/Lib/unittest/mock.py @@ -112,11 +112,24 @@ 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 - funcopy.__module__ = func.__module__ - funcopy.__defaults__ = func.__defaults__ - funcopy.__kwdefaults__ = func.__kwdefaults__ + try: + funcopy.__module__ = func.__module__ + except AttributeError: + pass + try: + funcopy.__defaults__ = func.__defaults__ + except AttributeError: + pass + try: + funcopy.__kwdefaults__ = func.__kwdefaults__ + except AttributeError: + pass def _callable(obj): |