Skip to content

Commit de93be5

Browse files
committed
Fix problem with symlink paths in unittest/loader.py
1 parent db3e990 commit de93be5

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

Lib/unittest/loader.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,10 @@ def _get_name_from_path(self, path):
356356
return '.'
357357
path = _splitext(os.path.normpath(path))
358358

359-
_relpath = os.path.relpath(path, self._top_level_dir)
359+
path_real = os.path.realpath(path)
360+
tld_real = os.path.realpath(self._top_level_dir)
361+
_relpath = os.path.relpath(path_real, tld_real)
362+
360363
assert not os.path.isabs(_relpath), "Path must be within the project"
361364
assert not _relpath.startswith('..'), "Path must be within the project"
362365

0 commit comments

Comments
 (0)