MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / _instance_callable

Function _instance_callable

tools/python-3.11.9-amd64/Lib/unittest/mock.py:166–178  ·  view source on GitHub ↗

Given an object, return True if the object is callable. For classes, return True if instances would be callable.

(obj)

Source from the content-addressed store, hash-verified

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

Callers 2

__enter__Method · 0.85
create_autospecFunction · 0.85

Calls 1

getMethod · 0.45

Tested by

no test coverage detected