Skip to content

Python unittest subtests failing with "Parent test item not found" in handleSubtestSuccess with test-by-project #26312

Open

Description

Type: Bug

Behavior

An existing Python project with unittest tests including subtests was working as expected:

screenshot-2.png

However, after adding to a multi-root workspace, the tests with sub-tests often (but not always) fail to properly display in the graphical Testing panel - while otherwise succeeding and as shown in the text "Test Results" panel.

screenshot-1.jpg

It appears this may be some sort of race condition? Most often, I will see completed and successful tests - though only 1 of the 3 subtests are even listed. The last 2 simply fail to be included in the list at all, and the test takes 5 seconds longer to run than the otherwise usual 0.5 seconds. In the example captured for this report, the tests incorrectly appear as "Skipped" in the graphical Testing panel, while the text "Test Results" panel shows a completed test - including the expected output from each of the 3 sub-tests.

Re-opening the project on its own, without the parent multi-root workspace, again results in the tests consistently completing and displaying as expected.

Issue reproduced in Windows Sandbox for the purpose of submitting this issue report.

Steps to reproduce:

  1. Use the provided minimal VS Code workspace as provided at https://github.com/ziesemer/vscode-python-issue-2026-11-20.
  2. Run the tests using the "Testing" pane.

Python Output (log)

Significant portion?

2026-11-20 19:14:54.842 [info] Started unittest discovery subprocess (environment extension) for workspace c:\Test\Project1
2026-11-20 19:14:55.017 [error] Falling back to tree search for test: test.Tests.test
2026-11-20 19:14:55.017 [error] Test Results named pipe \\.\pipe\python-test-results-c8fd2ac00d5ce7bdcc09 error: [Error: Parent test item not found
	at t.TestExecutionHandler.handleSubtestSuccess (c:\Users\WDAGUtilityAccount\.vscode\extensions\ms-python.python-2026.10.0-win32-x64\out\client\extension.js:2:990979)

Full output from run:

Click to expand
2026-11-20 19:14:35.433 [info] Environment discovery is managed by the Python Environments extension (ms-python.vscode-python-envs). Check the "Python Environments" output channel for environment-specific logs.
2026-11-20 19:14:35.533 [info] [test-by-project] Activating project-based testing mode
2026-11-20 19:14:35.533 [info] [test-by-project] Discovering projects for workspace: c:\Test
2026-11-20 19:14:35.533 [info] [test-by-project] Discovering projects for workspace: c:\Test\Project1
2026-11-20 19:14:35.534 [info] Native locator: Refresh started
2026-11-20 19:14:35.534 [info] [test-by-project] Found 2 total Python projects from API
2026-11-20 19:14:35.534 [info] [test-by-project] Filtered to 2 projects in workspace
2026-11-20 19:14:35.534 [info] [test-by-project] Creating adapter for: Test at file:///c%3A/Test
2026-11-20 19:14:35.534 [info] [test-by-project] Found 2 total Python projects from API
2026-11-20 19:14:35.534 [info] [test-by-project] Filtered to 1 projects in workspace
2026-11-20 19:14:35.534 [info] [test-by-project] Creating adapter for: Project1 at file:///c%3A/Test/Project1
2026-11-20 19:14:35.552 [info] [test-by-project] Creating adapter for: Project1 at file:///c%3A/Test/Project1
2026-11-20 19:14:35.552 [info] [test-by-project] Registered 1 project(s) for c:\Test\Project1
2026-11-20 19:14:35.553 [info] [test-by-project] Registered 2 project(s) for c:\Test
2026-11-20 19:14:35.554 [info] [test-by-project] Activated 2 project(s) for c:\Test
2026-11-20 19:14:35.554 [info] [test-by-project] Activated 1 project(s) for c:\Test\Project1
2026-11-20 19:14:35.554 [info] [test-by-project] Subscribed to Python project changes
2026-11-20 19:14:35.554 [info] [test-by-project] Subscribed to Python environment changes
2026-11-20 19:14:35.584 [info] > pyenv which python
2026-11-20 19:14:35.584 [info] cwd: c:\Test
2026-11-20 19:14:35.660 [info] Active interpreter [c:\Test]:  C:\Program Files\Python315\python.exe
2026-11-20 19:14:36.526 [info] Native locator: Refresh finished in 993 ms
2026-11-20 19:14:37.339 [info] Starting Pylance language server.
2026-11-20 19:14:39.343 [info] [test-by-project] Cleaned up 0 test items for workspace: c:\Test\Project1
2026-11-20 19:14:39.344 [info] [test-by-project] Discovering projects for workspace: c:\Test\Project1
2026-11-20 19:14:39.344 [info] [test-by-project] Found 2 total Python projects from API
2026-11-20 19:14:39.344 [info] [test-by-project] Filtered to 1 projects in workspace
2026-11-20 19:14:39.344 [info] [test-by-project] Creating adapter for: Project1 at file:///c%3A/Test/Project1
2026-11-20 19:14:39.345 [info] [test-by-project] Registered 1 project(s) for c:\Test\Project1
2026-11-20 19:14:39.346 [info] [test-by-project] Starting discovery for 1 project(s) in workspace
2026-11-20 19:14:39.346 [info] [test-by-project] Discovering tests for project: Project1 (Python 3.15)
2026-11-20 19:14:39.347 [info] Environment variables set for unittest discovery: TEST_RUN_PIPE=\\.\pipe\python-test-discovery-2b637b098ec875250762
2026-11-20 19:14:39.347 [info] [test-by-project] Setting PROJECT_ROOT_PATH=c:\Test\Project1 for unittest discovery
2026-11-20 19:14:39.347 [info] Using environment extension for unittest discovery in workspace c:\Test\Project1
2026-11-20 19:14:39.349 [info] Started unittest discovery subprocess (environment extension) for workspace c:\Test\Project1
2026-11-20 19:14:39.517 [info] Unittest discovery completed for workspace c:\Test\Project1
2026-11-20 19:14:39.517 [info] [test-by-project] Project Project1 (Python 3.15) discovery completed
2026-11-20 19:14:39.517 [info] [test-by-project] Discovery complete: 1/1 projects completed
2026-11-20 19:14:54.707 [info] Active interpreter [c:\Test\Project1]:  C:\Program Files\Python315\python.exe
2026-11-20 19:14:54.709 [info] [test-by-project] Executing tests across 1 project(s), debug=false
2026-11-20 19:14:54.709 [info] [test-by-project] Executing 1 test item(s) for project: Project1 (Python 3.15)
2026-11-20 19:14:54.709 [info] [test-by-project] Running 1 test(s) for project: Project1 (Python 3.15)
2026-11-20 19:14:54.709 [info] [test-by-project] Setting PROJECT_ROOT_PATH=c:\Test\Project1 for unittest execution
2026-11-20 19:14:54.709 [info] Running UNITTEST execution for the following test ids: test.Tests.test
2026-11-20 19:14:54.709 [info] Attempting to use temp directory for test ids file, file name: test-ids-53510ebb6cf104510bcd.txt
2026-11-20 19:14:54.719 [info] All environment variables set for unittest execution, PYTHONPATH: "c:\\Test\\Project1"
2026-11-20 19:14:54.765 [info] Skipping ActivatedEnv Detection:  process.env.VSCODE_CLI !== '1'
2026-11-20 19:14:54.774 [info] > pyenv which python
2026-11-20 19:14:54.774 [info] cwd: c:\Test\Project1
2026-11-20 19:14:54.832 [info] Running unittest with arguments: c:\Users\WDAGUtilityAccount\.vscode\extensions\ms-python.python-2026.10.0-win32-x64\python_files\unittestadapter\execution.py --udiscovery -v -s . -p *test*.py for workspace c:\Test\Project1 

2026-11-20 19:14:54.837 [info] [test-by-project] Cleaned up 1 test items for workspace: c:\Test\Project1
2026-11-20 19:14:54.837 [info] [test-by-project] Discovering projects for workspace: c:\Test\Project1
2026-11-20 19:14:54.837 [info] Active interpreter [global]:  C:\Program Files\Python315\python.exe
2026-11-20 19:14:54.837 [info] [test-by-project] Found 2 total Python projects from API
2026-11-20 19:14:54.837 [info] [test-by-project] Filtered to 1 projects in workspace
2026-11-20 19:14:54.837 [info] [test-by-project] Creating adapter for: Project1 at file:///c%3A/Test/Project1
2026-11-20 19:14:54.839 [info] [test-by-project] Registered 1 project(s) for c:\Test\Project1
2026-11-20 19:14:54.839 [info] [test-by-project] Starting discovery for 1 project(s) in workspace
2026-11-20 19:14:54.839 [info] [test-by-project] Discovering tests for project: Project1 (Python 3.15)
2026-11-20 19:14:54.840 [info] Environment variables set for unittest discovery: TEST_RUN_PIPE=\\.\pipe\python-test-discovery-e59614aed63f1c5ae243
2026-11-20 19:14:54.840 [info] [test-by-project] Setting PROJECT_ROOT_PATH=c:\Test\Project1 for unittest discovery
2026-11-20 19:14:54.840 [info] Using environment extension for unittest discovery in workspace c:\Test\Project1
2026-11-20 19:14:54.842 [info] Started unittest discovery subprocess (environment extension) for workspace c:\Test\Project1
2026-11-20 19:14:55.017 [error] Falling back to tree search for test: test.Tests.test
2026-11-20 19:14:55.017 [error] Test Results named pipe \\.\pipe\python-test-results-c8fd2ac00d5ce7bdcc09 error: [Error: Parent test item not found
	at t.TestExecutionHandler.handleSubtestSuccess (c:\Users\WDAGUtilityAccount\.vscode\extensions\ms-python.python-2026.10.0-win32-x64\out\client\extension.js:2:990979)
	at t.TestExecutionHandler.handleTestOutcome (c:\Users\WDAGUtilityAccount\.vscode\extensions\ms-python.python-2026.10.0-win32-x64\out\client\extension.js:2:989276)
	at t.TestExecutionHandler.processExecution (c:\Users\WDAGUtilityAccount\.vscode\extensions\ms-python.python-2026.10.0-win32-x64\out\client\extension.js:2:988833)
	at d.resolveExecution (c:\Users\WDAGUtilityAccount\.vscode\extensions\ms-python.python-2026.10.0-win32-x64\out\client\extension.js:2:983584)
	at c:\Users\WDAGUtilityAccount\.vscode\extensions\ms-python.python-2026.10.0-win32-x64\out\client\extension.js:2:1059045
	at S._callback (c:\Users\WDAGUtilityAccount\.vscode\extensions\ms-python.python-2026.10.0-win32-x64\out\client\extension.js:2:1008845)
	at b.callback (c:\Users\WDAGUtilityAccount\.vscode\extensions\ms-python.python-2026.10.0-win32-x64\out\client\extension.js:2:232826)
	at Object.thunk (c:\Users\WDAGUtilityAccount\.vscode\extensions\ms-python.python-2026.10.0-win32-x64\out\client\extension.js:2:1683478)
	at runNextTicks (node:internal/process/task_queues:65:5)
	at process.processImmediate (node:internal/timers:541:9)]
2026-11-20 19:14:55.017 [error] Falling back to tree search for test: test.Tests.test
2026-11-20 19:14:55.017 [error] Falling back to tree search for test: test.Tests.test
2026-11-20 19:14:55.017 [error] Falling back to tree search for test: test.Tests.test
2026-11-20 19:14:55.041 [info] Unittest discovery completed for workspace c:\Test\Project1
2026-11-20 19:14:55.041 [info] [test-by-project] Project Project1 (Python 3.15) discovery completed
2026-11-20 19:14:55.041 [info] [test-by-project] Discovery complete: 1/1 projects completed
2026-11-20 19:15:00.053 [info] [test-by-project] All project executions completed

Diagnostic data

Issue Details

Item Value
Issue Category Bug
Target Python
Repository Microsoft/vscode-python
VS Code Version Code 1.147.0 (8a14f0cc1b08d531eb83255ea3764ae22aa932b5, 2026-11-17T02:46:11Z)
OS Version Windows_NT x64 10.0.26100
Extension Identifier ms-python.python
Extension Version 2026.10.0
Extension Publisher ms-python

Additional Issue Data

issue-data.md

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    triage-neededNeeds assignment to the proper sub-team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions