(self)
| 26 | """check that 'import monai.xx.file_name' returns a module""" |
| 27 | |
| 28 | def test_files(self): |
| 29 | src_dir = os.path.dirname(TESTS_PATH) |
| 30 | monai_dir = os.path.join(src_dir, "monai") |
| 31 | py_files = glob.glob(os.path.join(monai_dir, "**", "*.py"), recursive=True) |
| 32 | for x in py_files: |
| 33 | if os.path.basename(x).startswith("_"): |
| 34 | continue |
| 35 | mod_name = x[len(src_dir) : -3] # create relative path |
| 36 | mod_name = mod_name[1:].replace(mod_name[0], ".") |
| 37 | mod, cls = mod_name.rsplit(".", 1) |
| 38 | obj, exist = optional_import(mod, name=cls) |
| 39 | if exist: |
| 40 | self.assertTrue(inspect.ismodule(obj), msg=mod_name) |
| 41 | |
| 42 | |
| 43 | if __name__ == "__main__": |
nothing calls this directly
no test coverage detected