def test_is_object_or_method(self): doc = pydoc.Doc() # Bound Method self.assertTrue(pydoc._is_some_method(doc.fail)) # Method Descriptor self.assertTrue(pydoc._is_some_method(int.__add__)) # String self.assertFalse(pydoc._is_some_method("I am not a method"))
def test_is_object_or_method(self): doc = pydoc.Doc() self.assertTrue(pydoc._is_some_method(doc.fail)) self.assertTrue(pydoc._is_some_method(int.__add__)) self.assertFalse(pydoc._is_some_method('I am not a method'))
print(aaa) def fun2(self): '''fun2 description''' print('function2') def doc(self, name): return pydoc.help(name) obj = testclass() aaa = obj.doc(obj.fun1) members = dir(obj) print('#' * 16) pydoc.Doc() des = pydoc.describe(obj) print(des) print('#' * 16) for m in sorted(members): if m.startswith('__'): pass else: print(m + '\n\t') fundef = inspect.getsource(eval('obj.%s' % m)) fundefstr = fundef[:fundef.find(':')] listoffun = fundef.split('\n') print(fundefstr) ret = eval('obj.%s.__doc__' % m) if ret: print('\t' + '\n\t'.join(ret.split('\n')))