コード例 #1
0
 def testMethod(self): #{{{
     '''Only pure method returns True'''
     class Test(object): #{{{
         def test(self): pass
         @classmethod
         def class_(cls): pass
         @staticmethod
         def static(): pass
     # End class #}}}
     for m in ('test', 'class_'):
         self.assertTrue(ismethod(getattr(Test, m)))
     self.assertFalse(ismethod(Test.static))
コード例 #2
0
 def testCallable(self): #{{{
     '''Arbitrary non-function callable returns False'''
     class Test(object): #{{{
         def __call__(self): #{{{
             pass
         # End def #}}}
     # End class #}}}
     for c in (Test, Test()):
         self.assertFalse(ismethod(c))
コード例 #3
0
 def testPythonObject(self): #{{{
     '''Arbitrary object returns False'''
     self.assertFalse(ismethod(1))
コード例 #4
0
 def testBuiltinFunction(self): #{{{
     '''Built-in function returns false'''
     self.assertFalse(ismethod(max))
コード例 #5
0
 def testPythonFunction(self): #{{{
     '''Pure python function returns False'''
     self.assertFalse(ismethod(ismethod))