9 def discover_tests(directory, callback):
11 for _f in os.listdir(directory):
12 f = "%s/%s" % (directory, _f)
14 discover_tests(f, callback)
16 if not os.path.isfile(f):
19 sys.path.insert(0, directory)
21 if not _f.startswith("test_") or not _f.endswith(".py"):
23 name = "".join(f.split("/")[-1].split(".")[:-1])
24 module = importlib.import_module(name)
25 for name, cls in module.__dict__.items():
26 if not isinstance(cls, type):
28 if not issubclass(cls, unittest.TestCase):
32 or name == "VppAsfTestCase"
33 or name.startswith("Template")
36 for method in dir(cls):
37 if not callable(getattr(cls, method)):
39 if method.startswith("test_"):
40 callback(_f, cls, method)
43 def print_callback(file_name, cls, method):
44 print("%s.%s.%s" % (file_name, cls.__name__, method))