if isclass(object) or ismethod(object) or isfunction(object):
# mutual exclusion
return False
+ if isinstance(object, functools.partial):
+ # Lie for children. The addition of partial.__get__
+ # doesn't currently change the partial objects behaviour,
+ # not counting a warning about future changes.
+ return False
tp = type(object)
return (hasattr(tp, "__get__")
and not hasattr(tp, "__set__")
self.assertFalse(inspect.isroutine(type))
self.assertFalse(inspect.isroutine(int))
self.assertFalse(inspect.isroutine(type('some_class', (), {})))
+ # partial
+ self.assertFalse(inspect.isroutine(functools.partial(mod.spam)))
def test_isclass(self):
self.istest(inspect.isclass, 'mod.StupidGit')
self.assertFalse(inspect.ismethoddescriptor(Owner.static_method))
self.assertFalse(inspect.ismethoddescriptor(function))
self.assertFalse(inspect.ismethoddescriptor(a_lambda))
+ self.assertFalse(inspect.ismethoddescriptor(functools.partial(function)))
def test_descriptor_being_a_class(self):
class MethodDescriptorMeta(type):