8000 Changed path to dot before import · python/cpython@715a5d3 · GitHub
[go: up one dir, main page]

Skip to content

Commit 715a5d3

Browse files
Changed path to dot before import
1 parent 82c4360 commit 715a5d3

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Lib/unittest/loader.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,11 @@ def discover(self, start_dir, pattern='test*.py', top_level_dir=None):
290290
if os.path.isdir(os.path.abspath(start_dir)):
291291
if os.path.abspath(start_dir) != top_level_dir:
292292
try:
293-
__import__(os.path.relpath(start_dir, top_level_dir))
293+
# Convert to dot import
294+
dot_import = '.'.join(
295+
os.path.relpath(start_dir, top_level_dir).split(os.sep)
296+
)
297+
__import__(dot_import)
294298
except ImportError:
295299
raise ImportError('Start directory is not importable: %r' % start_dir)
296300

0 commit comments

Comments
 (0)
0