Skip to content

Commit 30a1e63

Browse files
committed
Fix -u test discovery in runner.py using pathlib for improved path handling
1 parent 8d4a657 commit 30a1e63

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

tests/runner.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from __future__ import annotations
1313

1414
import argparse
15-
import glob
15+
from pathlib import Path
1616
import inspect
1717
import os
1818
import re
@@ -124,11 +124,18 @@ def get_default_pattern(loader):
124124
# Get all test names (optionally from some path with some pattern)
125125
with PerfContext() as pc:
126126
# the files are searched from `tests/` folder, starting with `test_`
127-
files = glob.glob(os.path.join(os.path.dirname(__file__), "test_*.py"))
127+
tests_path = Path(__file__).parent / args.path
128+
files = {
129+
file.relative_to(tests_path).as_posix().replace("/", ".").replace(".py", "")
130+
for file in tests_path.rglob("test_*.py")
131+
}
132+
# import pdb
133+
# pdb.set_trace()
134+
128135
cases = []
129-
for test_module in {os.path.basename(f)[:-3] for f in files}:
136+
for test_module in files:
130137
if re.match(args.pattern, test_module):
131-
cases.append(f"tests.{test_module}")
138+
cases.append(f"{test_module}")
132139
else:
133140
print(f"monai test runner: excluding tests.{test_module}")
134141
print(cases)

0 commit comments

Comments
 (0)