Skip to content

fix(testing): propagate PROJECT_ROOT_PATH and PYTHONPATH during test debugging - #26230

Open
MOHAMMED WASIM KHAN (wasim-builds) wants to merge 2 commits into
microsoft:mainfrom
wasim-builds:fix-26155-unittest-debug-subdirs
Open

MOHAMMED WASIM KHAN (wasim-builds) wants to merge 2 commits into
microsoft:mainfrom
wasim-builds:fix-26155-unittest-debug-subdirs

Conversation

@wasim-builds

Copy link
Copy Markdown

Fixes #26155

Description

When debugging unittest tests located in subdirectories (such as with -s ./test), the debug execution previously failed to match test IDs, reporting tests as skipped with no output:

  1. debugLauncher.ts previously omitted forwarding PROJECT_ROOT_PATH onto the debuggee's environment variables (launchArgs.env).
  2. addPathToPythonpath was called without assigning the returned path back to launchArgs.env.PYTHONPATH.
  3. In execution.py and discovery.py, top_level_dir now consistently defaults to PROJECT_ROOT_PATH when an explicit -t top-level directory is not supplied.

Changes

  • In src/client/testing/common/debugLauncher.ts:
    • Set launchArgs.env.PROJECT_ROOT_PATH = options.project.uri.fsPath when options.project is provided.
    • Assigned launchArgs.env.PYTHONPATH = addPathToPythonpath(additionalPythonPath, launchArgs.env.PYTHONPATH).
  • In python_files/unittestadapter/execution.py:
    • Default top_level_dir to project_root_path if top_level_dir is None.
  • In python_files/unittestadapter/discovery.py:
    • Default top_level_dir to project_root_path when not top_level_dir, preserving any explicit -t arguments.
  • Added regression unit tests in both src/test/testing/common/debugLauncher.unit.test.ts and python_files/tests/unittestadapter/test_execution.py.

…debugging

Fixes microsoft#26155

When debugging tests (e.g. unittest with custom start directory `-s`),
the debug configuration previously dropped `PROJECT_ROOT_PATH` and
failed to assign the updated `PYTHONPATH` resulting from
`addPathToPythonpath`. In addition, `execution.py` and `discovery.py`
now consistently default `top_level_dir` to `PROJECT_ROOT_PATH` while
preserving any explicitly specified `-t` option.
Copilot AI balanced review requested due to automatic review settings October 17, 2026 10:31

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Debugging unittest tests silently reports "skipped" when -s points at a subdirectory

2 participants