| def discover_tests(directory, callback): |
| for _f in os.listdir(directory): |
| f = "%s/%s" % (directory, _f) |
| discover_tests(f, callback) |
| if not os.path.isfile(f): |
| sys.path.insert(0, directory) |
| if not _f.startswith("test_") or not _f.endswith(".py"): |
| name = "".join(f.split("/")[-1].split(".")[:-1]) |
| module = importlib.import_module(name) |
| for name, cls in module.__dict__.items(): |
| if not isinstance(cls, type): |
| if not issubclass(cls, unittest.TestCase): |
| if name == "VppTestCase" or name.startswith("Template"): |
| if not callable(getattr(cls, method)): |
| if method.startswith("test_"): |
| callback(_f, cls, method) |
| def print_callback(file_name, cls, method): |
| print("%s.%s.%s" % (file_name, cls.__name__, method)) |