Skip to content

Commit

Permalink
[DLMED] fix windows test
Browse files Browse the repository at this point in the history
Signed-off-by: Nic Ma <[email protected]>
  • Loading branch information
Nic-Ma committed Dec 20, 2021
1 parent 1a9bb2d commit 87495ef
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
19 changes: 9 additions & 10 deletions monai/apps/mmars/config_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,17 @@ def __init__(self, pkgs: Sequence[str], modules: Sequence[str]):
def _create_classes_table(self):
class_table = {}
for pkg in self.pkgs:
package = __import__(pkg)
package = importlib.import_module(pkg)

for _, modname, _ in pkgutil.walk_packages(path=package.__path__, prefix=package.__name__ + "."):
if modname.startswith(pkg):
if any(name in modname for name in self.modules):
try:
module = importlib.import_module(modname)
for name, obj in inspect.getmembers(module):
if inspect.isclass(obj) and obj.__module__ == modname:
class_table[name] = modname
except ModuleNotFoundError:
pass
if any(name in modname for name in self.modules):
try:
module = importlib.import_module(modname)
for name, obj in inspect.getmembers(module):
if inspect.isclass(obj) and obj.__module__ == modname:
class_table[name] = modname
except ModuleNotFoundError:
pass
return class_table

def get_module_name(self, class_name):
Expand Down
2 changes: 0 additions & 2 deletions tests/test_config_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

from monai.apps import ConfigParser
from monai.transforms import LoadImaged
from tests.utils import skip_if_windows

TEST_CASE_1 = [
dict(pkgs=["monai"], modules=["transforms"]),
Expand Down Expand Up @@ -56,7 +55,6 @@ def test_type(self, input_param, test_input, output_type):
self.assertEqual(result, output_type)


@skip_if_windows
class TestConfigParserExternal(unittest.TestCase):
@parameterized.expand([TEST_CASE_4])
def test_type(self, input_param, test_input, output_type):
Expand Down

0 comments on commit 87495ef

Please sign in to comment.