小编Moz*_*zey的帖子

如何调用通过inspect.getmembers发现的方法?

import re
import sys
import inspect
import testcases

testClass = re.compile(r'.*Case$')
testMethod = re.compile(r'.*Test$')

for class_name, class_obj in inspect.getmembers(testcases, inspect.isclass):
    if testClass.match(class_name):
        for method_name, method_obj in inspect.getmembers(class_obj, inspect.ismethod):
            if testMethod.match(method_name):
                # RIGHT HERE I WOULD LIKE TO INVOKE method_name
Run Code Online (Sandbox Code Playgroud)

python inspect

2
推荐指数
1
解决办法
1211
查看次数

标签 统计

inspect ×1

python ×1