def test_is_callable(self): class OldCallable: def __call__(self): pass class Callable(object): def __call__(self): pass class OldNoncallable: pass class Noncallable(object): pass def spam(): pass class CallableMethod(object): def method(self): pass self.assertTrue(inspection.is_callable(spam)) self.assertTrue(inspection.is_callable(Callable)) self.assertTrue(inspection.is_callable(Callable())) self.assertTrue(inspection.is_callable(OldCallable)) self.assertTrue(inspection.is_callable(OldCallable())) self.assertFalse(inspection.is_callable(Noncallable())) self.assertFalse(inspection.is_callable(OldNoncallable())) self.assertFalse(inspection.is_callable(None)) self.assertTrue(inspection.is_callable(CallableMethod().method))
def test_is_callable(self): self.assertTrue(inspection.is_callable(spam)) self.assertTrue(inspection.is_callable(Callable)) self.assertTrue(inspection.is_callable(Callable())) self.assertTrue(inspection.is_callable(OldCallable)) self.assertTrue(inspection.is_callable(OldCallable())) self.assertFalse(inspection.is_callable(Noncallable())) self.assertFalse(inspection.is_callable(OldNoncallable())) self.assertFalse(inspection.is_callable(None)) self.assertTrue(inspection.is_callable(CallableMethod().method))
def _callable_postfix(value, word): """rlcompleter's _callable_postfix done right.""" with inspection.AttrCleaner(value): if inspection.is_callable(value): word += '(' return word
def _callable_postfix(self, value, word): """rlcompleter's _callable_postfix done right.""" with inspection.AttrCleaner(value): if inspection.is_callable(value): word += '(' return word