示例#1
0
    def test_call_magic_method(self):
        class Callable:
            def __call__(self):
                pass

        instance = Callable()
        self.assertTrue(_callable(instance))
示例#2
0
    def test_classmethod(self):
        class WithClassMethod:
            @classmethod
            def classfunc(cls):
                pass

        self.assertTrue(_callable(WithClassMethod.classfunc))
示例#3
0
    def test_staticmethod(self):
        class WithStaticMethod:
            @staticmethod
            def staticfunc():
                pass

        self.assertTrue(_callable(WithStaticMethod.staticfunc))
示例#4
0
    def test_non_callable_classmethod(self):
        class BadClassMethod:
            not_callable = classmethod(None)

        self.assertFalse(_callable(BadClassMethod.not_callable))
示例#5
0
    def test_non_callable_staticmethod(self):
        class BadStaticMethod:
            not_callable = staticmethod(None)

        self.assertFalse(_callable(BadStaticMethod.not_callable))
示例#6
0
 def test_non_callable_classmethod(self):
     class BadClassMethod:
         not_callable = classmethod(None)
     self.assertFalse(_callable(BadClassMethod.not_callable))
示例#7
0
 def test_type(self):
     for obj in [str, bytes, int, list, tuple, SomeClass]:
         self.assertTrue(_callable(obj))
示例#8
0
 def test_classmethod(self):
     class WithClassMethod:
         @classmethod
         def classfunc(cls): pass
     self.assertTrue(_callable(WithClassMethod.classfunc))
示例#9
0
 def test_non_callable_staticmethod(self):
     class BadStaticMethod:
         not_callable = staticmethod(None)
     self.assertFalse(_callable(BadStaticMethod.not_callable))
示例#10
0
 def test_staticmethod(self):
     class WithStaticMethod:
         @staticmethod
         def staticfunc(): pass
     self.assertTrue(_callable(WithStaticMethod.staticfunc))
示例#11
0
 def test_call_magic_method(self):
     class Callable:
         def __call__(self): pass
     instance = Callable()
     self.assertTrue(_callable(instance))
示例#12
0
 def test_type(self):
     for obj in [str, bytes, int, list, tuple, SomeClass]:
         self.assertTrue(_callable(obj))