Given an object, return True if the object is callable. For classes, return True if instances would be callable.
(obj)
| 168 | |
| 169 | |
| 170 | def _instance_callable(obj): |
| 171 | """Given an object, return True if the object is callable. |
| 172 | For classes, return True if instances would be callable.""" |
| 173 | if not isinstance(obj, type): |
| 174 | # already an instance |
| 175 | return getattr(obj, '__call__', None) is not None |
| 176 | |
| 177 | # *could* be broken by a class overriding __mro__ or __dict__ via |
| 178 | # a metaclass |
| 179 | for base in (obj,) + obj.__mro__: |
| 180 | if base.__dict__.get('__call__') is not None: |
| 181 | return True |
| 182 | return False |
| 183 | |
| 184 | |
| 185 | def _set_signature(mock, original, instance=False): |
no test coverage detected
searching dependent graphs…