コード例 #1
0
ファイル: test_inspection.py プロジェクト: wevial/bpython
    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))
コード例 #2
0
 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))
コード例 #3
0
ファイル: test_inspection.py プロジェクト: dannykansas/edu
 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))
コード例 #4
0
ファイル: autocomplete.py プロジェクト: pombredanne/bpython
def _callable_postfix(value, word):
    """rlcompleter's _callable_postfix done right."""
    with inspection.AttrCleaner(value):
        if inspection.is_callable(value):
            word += '('
    return word
コード例 #5
0
 def _callable_postfix(self, value, word):
     """rlcompleter's _callable_postfix done right."""
     with inspection.AttrCleaner(value):
         if inspection.is_callable(value):
             word += '('
     return word