Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Lib/unittest/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,10 @@ def _get_name_from_path(self, path):
return '.'
path = _splitext(os.path.normpath(path))

_relpath = os.path.relpath(path, self._top_level_dir)
path_real = os.path.realpath(path)
tld_real = os.path.realpath(self._top_level_dir)
_relpath = os.path.relpath(path_real, tld_real)

assert not os.path.isabs(_relpath), "Path must be within the project"
assert not _relpath.startswith('..'), "Path must be within the project"

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Test discovery would fail when the path to the source tree contains a
symlink. Paths that take an alternate route to the same place (eg just the
real path) would not be considered a subpath, and cause an assert. Instead,
always resolve to the real path before comparing.
Loading