mirror of
https://github.com/python/cpython.git
synced 2025-10-13 10:23:28 +00:00
bpo-23078: Add support for {class,static}method to mock.create_autospec() (GH-11613)
Co-authored-by: Felipe <felipe.nospam.ochoa@gmail.com>
This commit is contained in:
parent
9541bd321a
commit
9b21856b0f
5 changed files with 81 additions and 2 deletions
|
@ -29,7 +29,7 @@ import inspect
|
|||
import pprint
|
||||
import sys
|
||||
import builtins
|
||||
from types import ModuleType
|
||||
from types import ModuleType, MethodType
|
||||
from unittest.util import safe_repr
|
||||
from functools import wraps, partial
|
||||
|
||||
|
@ -122,6 +122,8 @@ def _copy_func_details(func, funcopy):
|
|||
def _callable(obj):
|
||||
if isinstance(obj, type):
|
||||
return True
|
||||
if isinstance(obj, (staticmethod, classmethod, MethodType)):
|
||||
return _callable(obj.__func__)
|
||||
if getattr(obj, '__call__', None) is not None:
|
||||
return True
|
||||
return False
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue