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