Skip to content

Commit 2481afb

Browse files
committed
fix text discovery
1 parent 9f3474e commit 2481afb

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

tests/runner.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,15 +126,18 @@ def get_default_pattern(loader):
126126
# the files are searched from `tests/` folder, starting with `test_`
127127
tests_path = Path(__file__).parent / args.path
128128
files = {
129-
file.relative_to(tests_path).as_posix().replace("/", ".").replace(".py", "")
130-
for file in tests_path.rglob("test_*.py")
129+
file.relative_to(tests_path).as_posix()
130+
for file in tests_path.rglob("test_*py")
131+
if re.search(args.pattern, file.name)
131132
}
133+
print(files)
132134
cases = []
133-
for test_module in files:
134-
if re.match(args.pattern, test_module):
135-
cases.append(test_module)
135+
for test_module in tests_path.rglob("test_*py"):
136+
case_str = str(test_module.relative_to(tests_path).as_posix()).replace("/", ".")[:-3]
137+
if case_str in files:
138+
cases.append(f"tests.{case_str}")
136139
else:
137-
print(f"monai test runner: excluding {test_module}")
140+
print(f"monai test runner: excluding {test_module.name}")
138141
print(cases)
139142
tests = unittest.TestLoader().loadTestsFromNames(cases)
140143
discovery_time = pc.total_time

0 commit comments

Comments
 (0)