python / python/cpython

_get_name_from_path() in Lib/unittest/loader.py fails when src path contains symlinks

Open
#149,141 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

stdlib type-bug
Dominant language
Python
Stars
77.2k
Forks
35.9k
PR merge metrics
PR metrics pending

Description

Bug report

Bug description:

This is conceptually somewhat similar to gh-148314

When the path to the source tree is via a symlink, an alternate path to the same will cause _get_name_from_path() to assert, thinking the supplied path is not a sub-path of the src tree. During the run of unittest's test suite, "." is passed as a path which is resolved to an absolute path - which of course doesn't match a symlinked path.

CPython versions tested on:

CPython main branch

Operating systems tested on:

macOS

Linked PRs
  • gh-149143

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in Lib/unittest/loader.py at _get_name_from_path(), then run the unittest test suite using a source-tree path reached through a symlink. Done means the alternate path no longer triggers the sub-path assertion and the relevant regression coverage passes; gh-149143 is already linked to this issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
testing-qa
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.