Skip to content

Test Discovery fails with unittests #25448

Closed
microsoft/vscode-python-environments
#849

Description

@irenepc

Type: Bug

Behaviour

Seemingly regardless of configurations, I get the error in the output panel regarding not being able to read properties of null.
This happens whenever I try to discover tests in my multi-root project. I'm guessing I get the error once for each root it fails to discover tests on?

Steps to reproduce:

  1. Attempt test discovery on a multi-root project?

I have tried changes in configuration, but they seem to have no effect, or give any different errors.

Diagnostic data

Output for Python in the Output panel (View→Output, change the drop-down the upper-right of the Output panel to Python)

2025-09-08 04:55:08.864 [info] > pyenv which python
2025-09-08 04:55:08.865 [info] cwd: y:\irenec\vscode
2025-09-08 04:55:12.270 [info] Active interpreter [y:\irenec\vscode]: c:\Python311\python.exe
2025-09-08 04:55:12.270 [info] Active interpreter [y:\irenec\dev\pipeline\src]: c:\Python311\python.exe
2025-09-08 04:55:12.271 [info] Active interpreter [y:\irenec\dev\pipelaunch\pipelaunch]: c:\Python311\python.exe
2025-09-08 04:55:12.272 [info] Discover tests for workspace name: vscode - root - uri: y:\irenec\vscode
2025-09-08 04:55:12.273 [info] Discover tests for workspace name: pipeline - uri: y:\irenec\dev\pipeline\src
2025-09-08 04:55:12.273 [info] Discover tests for workspace name: pipelaunch - uri: y:\irenec\dev\pipelaunch\pipelaunch
2025-09-08 04:55:13.018 [error] Test Discovery named pipe \.\pipe\python-test-discovery-c10f207410eb3ea75b73 error: TypeError: Cannot read properties of null (reading 'path')
at e (c:\Users\irenec.vscode\extensions\ms-python.python-2025.12.0-win32-x64\out\client\extension.js:2:967372)
at t.PythonResultResolver._resolveDiscovery (c:\Users\irenec.vscode\extensions\ms-python.python-2025.12.0-win32-x64\out\client\extension.js:2:951953)
at t.PythonResultResolver.resolveDiscovery (c:\Users\irenec.vscode\extensions\ms-python.python-2025.12.0-win32-x64\out\client\extension.js:2:951037)
at c:\Users\irenec.vscode\extensions\ms-python.python-2025.12.0-win32-x64\out\client\extension.js:2:1001847
at _._callback (c:\Users\irenec.vscode\extensions\ms-python.python-2025.12.0-win32-x64\out\client\extension.js:2:966565)
at b.callback (c:\Users\irenec.vscode\extensions\ms-python.python-2025.12.0-win32-x64\out\client\extension.js:2:227145)
at Object.thunk (c:\Users\irenec.vscode\extensions\ms-python.python-2025.12.0-win32-x64\out\client\extension.js:2:2032978)
2025-09-08 04:55:13.021 [error] Test Discovery named pipe \.\pipe\python-test-discovery-4d9602ac96f2e0990b34 error: TypeError: Cannot read properties of null (reading 'path')
at e (c:\Users\irenec.vscode\extensions\ms-python.python-2025.12.0-win32-x64\out\client\extension.js:2:967372)
at t.PythonResultResolver._resolveDiscovery (c:\Users\irenec.vscode\extensions\ms-python.python-2025.12.0-win32-x64\out\client\extension.js:2:951953)
at t.PythonResultResolver.resolveDiscovery (c:\Users\irenec.vscode\extensions\ms-python.python-2025.12.0-win32-x64\out\client\extension.js:2:951037)
at c:\Users\irenec.vscode\extensions\ms-python.python-2025.12.0-win32-x64\out\client\extension.js:2:1001847
at _._callback (c:\Users\irenec.vscode\extensions\ms-python.python-2025.12.0-win32-x64\out\client\extension.js:2:966565)
at b.callback (c:\Users\irenec.vscode\extensions\ms-python.python-2025.12.0-win32-x64\out\client\extension.js:2:227145)
at Object.thunk (c:\Users\irenec.vscode\extensions\ms-python.python-2025.12.0-win32-x64\out\client\extension.js:2:2032978)
2025-09-08 04:55:14.575 [info] Starting Pylance language server.
2025-09-08 04:55:18.882 [error] Test Discovery named pipe \.\pipe\python-test-discovery-a875b4296ff110b8e494 error: TypeError: Cannot read properties of null (reading 'path')
at e (c:\Users\irenec.vscode\extensions\ms-python.python-2025.12.0-win32-x64\out\client\extension.js:2:967372)
at t.PythonResultResolver._resolveDiscovery (c:\Users\irenec.vscode\extensions\ms-python.python-2025.12.0-win32-x64\out\client\extension.js:2:951953)
at t.PythonResultResolver.resolveDiscovery (c:\Users\irenec.vscode\extensions\ms-python.python-2025.12.0-win32-x64\out\client\extension.js:2:951037)
at c:\Users\irenec.vscode\extensions\ms-python.python-2025.12.0-win32-x64\out\client\extension.js:2:1001847
at _._callback (c:\Users\irenec.vscode\extensions\ms-python.python-2025.12.0-win32-x64\out\client\extension.js:2:966565)
at b.callback (c:\Users\irenec.vscode\extensions\ms-python.python-2025.12.0-win32-x64\out\client\extension.js:2:227145)
at Object.thunk (c:\Users\irenec.vscode\extensions\ms-python.python-2025.12.0-win32-x64\out\client\extension.js:2:2032978)

Extension version: 2025.12.0
VS Code version: Code 1.103.2 (6f17636121051a53c88d3e605c491d22af2ba755, 2025-08-20T16:45:34.255Z)
OS version: Windows_NT x64 10.0.19045
Modes:

  • Python version (& distribution if applicable, e.g. Anaconda): 3.11.9
  • Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): System
  • Value of the python.languageServer setting: Default
User Settings

Multiroot scenario, following user settings may not apply:

languageServer: "Pylance"

testing
• unittestArgs: "<placeholder>"
• unittestEnabled: true

Installed Extensions
Extension Name Extension Id Version
auto-comment-blocks kev 1.0.1
autodocstring njp 0.6.1
copilot Git 1.364.0
copilot-chat Git 0.30.3
debugpy ms- 2025.10.0
extendscript-debug Ado 2.1.0
gitlens eam 17.4.1
js-debug ms- 1.102.0
js-debug-companion ms- 1.1.3
python ms- 2025.12.0
vscode-js-profile-table ms- 1.0.10
vscode-pull-request-github Git 0.116.2
vscode-pylance ms- 2025.7.1
vscode-python-envs ms- 1.2.0
System Info
Item Value
CPUs Intel(R) Xeon(R) W-2225 CPU @ 4.10GHz (8 x 4104)
GPU Status 2d_canvas: enabled
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
trees_in_viz: disabled_off
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off
Load (avg) undefined
Memory (System) 63.69GB (49.00GB free)
Process Argv Y:\irenec\vscode\irenec_pipelaunch20.code-workspace --crash-reporter-id 0f3862e7-250e-488d-8961-f1c20f56d1d7
Screen Reader no
VM 0%
A/B Experiments
vsliv368:30146709
binariesv615:30325510
nativeloc1:31344060
dwcopilot:31170013
dwoutputs:31242946
copilot_t_ci:31333650
e5gg6876:31282496
996jf627:31283433
pythonrdcb7:31342333
usemplatestapi:31297334
aj953862:31281341
nesew2to5:31336538
agentclaude:31374413
nes-set-on:31340697
63221493:31336333
0927b901:31350571
aa_t:31379598
45650338:31358607
0cj2b977:31352657
gemagent1:31368469
cloudbuttont:31379625
retryenabled:31370050
3efgi100_wstrepl:31374188
trigger-command-fix:31379601

Activity

  1. eleanorjboyd commented on Sep 8, 2025

    @eleanorjboyd
    Member

    will investigate- thanks

  2. slegt commented on Sep 12, 2025

    @slegt

    Test discovery fails, even in normal projects.

    Output for Python in the Output panel (View→Output, change the drop-down the upper-right of the Output panel to Python)

    2025-09-12 13:27:25.717 [info] Native locator: Refresh started
    2025-09-12 13:27:25.830 [info] > conda info --json
    2025-09-12 13:27:28.767 [info] > pyenv which python
    2025-09-12 13:27:28.768 [info] cwd: c:\Users\Simon Legtenborg\PycharmProjects\example_project
    2025-09-12 13:27:29.817 [info] Native locator: Refresh finished in 4101 ms
    2025-09-12 13:27:29.825 [info] Active interpreter [c:\Users\Simon Legtenborg\PycharmProjects\example_project]:  C:\Users\Simon Legtenborg\AppData\Local\Programs\Python\Python312\python.exe
    2025-09-12 13:27:31.448 [info] Starting Pylance language server.
    2025-09-12 13:28:12.750 [info] Discover tests for workspace name: example_project - uri: c:\Users\Simon Legtenborg\PycharmProjects\example_project
    2025-09-12 13:28:12.753 [error] Subprocess exited unsuccessfully with exit code null and signal null on workspace c:\Users\Simon Legtenborg\PycharmProjects\example_project
    

    Output for Python Environment in the Output panel (View→Output, change the drop-down the upper-right of the Output panel to Python)

    2025-09-12 13:27:30.618 [info] Pipenv not found
    2025-09-12 13:27:30.618 [info] Pipenv not found, turning off pipenv features.
    2025-09-12 13:27:30.619 [info] Pyenv not found, turning off pyenv features.
    2025-09-12 13:27:30.620 [info] resolveDefaultInterpreter setting exists; found defaultEnvManager: ms-python.python:venv
    2025-09-12 13:27:30.634 [info] Resolved Python Environment C:\Users\Simon Legtenborg\AppData\Local\Programs\Python\Python312\python.exe
    2025-09-12 13:28:12.752 [info] Running in background: "C:\Users\Simon Legtenborg\AppData\Local\Programs\Python\Python312\python.exe" c:\Users\Simon Legtenborg\.vscode\extensions\ms-python.python-2025.14.0-win32-x64\python_files\unittestadapter\discovery.py --udiscovery -v -s . -p *test.py
    2025-09-12 13:28:12.753 [error] Process error: spawn "C:\Users\Simon Legtenborg\AppData\Local\Programs\Python\Python312\python.exe" ENOENT
    Error: spawn "C:\Users\Simon Legtenborg\AppData\Local\Programs\Python\Python312\python.exe" ENOENT
        at Process.ChildProcess._handle.onexit (node:internal/child_process:285:19)
        at onErrorNT (node:internal/child_process:483:16)
        at processTicksAndRejections (node:internal/process/task_queues:90:21)
    

    This happens for various different selected python interpreters.
    C:\Users\Simon Legtenborg\AppData\Local\Programs\Python\Python312\python.exe is a valid python path.

  3. eleanorjboyd commented on Sep 12, 2025

    @eleanorjboyd
    Member

    Hi! Has this worked before and is no longer working (like is this specifically a regression you are seeing)? Can you try running the following from your terminal and see if it works? "C:\Users\Simon Legtenborg\AppData\Local\Programs\Python\Python312\python.exe" c:\Users\Simon Legtenborg\.vscode\extensions\ms-python.python-2025.14.0-win32-x64\python_files\unittestadapter\discovery.py --udiscovery -v -s . -p *test.py you may need to put quotations around the "*test.py". Just wondering if you get the error "UNITTEST ERROR: TEST_RUN_PIPE is not set at the time of unittest trying to send data. Pl...." like I do when I attempt it

  4. slegt commented on Sep 12, 2025

    @slegt

    It seems that the issue is caused by the newest VS code Windows version. After downgrading to the July build, everything works as expected.

    Yes, im got the same result as you.

  5. eleanorjboyd commented on Sep 12, 2025

    @eleanorjboyd
    Member

    On the newest build can you try setting python.useEnvironmentsExtension in your user settings to false and see if that makes a difference? Also are you able to run a python file (like with the run button in the top corner) or does it also provide an error? Trying to narrow down which execution functionalities work and not as it is likely related to that

  6. slegt commented on Sep 15, 2025

    @slegt

    This unfortunately doesn't do anything. However, i noticed that the command

    "C:\Users\Simon Legtenborg\AppData\Local\Programs\Python\Python312\python.exe" "c:\Users\Simon Legtenborg\.vscode\extensions\ms-python.python-2025.14.0-win32-x64\python_files\unittestadapter\discovery.py" --udiscovery -v -s . -p *test.py
    

    is working fine for Windows Terminal, but not for PowerShell due to the Whitespace in the Path. To resolve this, one needs to use the call operator (&):

    & "C:\Users\Simon Legtenborg\AppData\Local\Programs\Python\Python312\python.exe" "c:\Users\Simon Legtenborg\.vscode\extensions\ms-python.python-2025.14.0-win32-x64\python_files\unittestadapter\discovery.py" --udiscovery -v -s . -p *test.py
    
  7. DiegoMont commented on Sep 17, 2025

    @DiegoMont

    I am having the same problem. Previously it was working:

    Output for Python in the Output panel:

    2025-09-16 20:50:25.924 [info] Discover tests for workspace name: backend - uri: /Users/diegomontano/dev/menu/backend
    2025-09-16 20:50:25.927 [info] arg: --rootdir already exists in args, not adding.
    2025-09-16 20:50:25.927 [info] Environment variables set for pytest discovery: PYTHONPATH=/Users/diegomontano/.vscode/extensions/ms-python.python-2025.14.0-darwin-arm64/python_files, TEST_RUN_PIPE=/var/folders/jv/7_zjlps536g19j5lpwnbzsbc0000gn/T/python-test-discovery-db4ee1e0d5ae8639042e
    2025-09-16 20:50:25.928 [error] Subprocess exited unsuccessfully with exit code null and signal null on workspace /Users/diegomontano/dev/qr-menu/backend
    2025-09-16 20:50:25.928 [error] pytest test discovery error for workspace:  /Users/diegomontano/dev/menu/backend 
      
     The python test process was terminated before it could exit on its own, the process errored with: Code: null, Signal: null for workspace /Users/diegomontano/dev/menu/backend
    

    Output for Python Environments in the Output panel:

    2025-09-16 20:50:18.385 [info] === Conda Shell Activation Map Generation ===
    Environment Configuration:
        - Identifier: "py312_django"
        - Prefix: "/Users/diegomontano/miniconda3/envs/py312_django"
        - Name: "py312_django"
    
    Local Activation:
        - Status: Found
        - Path: /Users/diegomontano/miniconda3/bin/activate
    
    Preferred Sourcing:
        - Selected Path: /Users/diegomontano/miniconda3/bin/activate
        - Source: Local
    
    ✓ Using source command with preferred path
    ==========================================
    2025-09-16 20:50:18.385 [info] Found named environment: /Users/diegomontano/miniconda3/envs/py312_django
    2025-09-16 20:50:19.157 [info] Terminal is activated: /Users/diegomontano/miniconda3/envs/py312_django
    2025-09-16 20:50:25.928 [info] Running in background: conda run --name py312_django python -m pytest -p vscode_pytest --collect-only --ds=backend.settings tests --rootdir=/Users/diegomontano/dev/menu/backend
    2025-09-16 20:50:25.928 [error] Process error: spawn conda ENOENT
    Error: spawn conda ENOENT
        at Process.ChildProcess._handle.onexit (node:internal/child_process:285:19)
        at onErrorNT (node:internal/child_process:483:16)
        at processTicksAndRejections (node:internal/process/task_queues:90:21)
    
    

    Extension version: 2025.14.0
    VS Code version: Version: 1.104.0 (Universal)
    OS version: macOS Sequoia 15.6.1

    I will be happy to share any additional details about my IDE settings :)

  8. DiegoMont commented on Sep 18, 2025

    @DiegoMont

    I downloaded the newest version of vscode (1.104.1) and the problem was gone 👍

  9. irenepc commented on Sep 19, 2025

    @irenepc
    Author

    I'm also no longer seeing the TypeError: Cannot read properties of null (reading 'path') error on 1.104.1
    Tests are still not being discovered, but I'll tweak my settings to see if I can get them to be discovered now.

  10. irenepc commented on Sep 19, 2025

    @irenepc
    Author

    Hi! Has this worked before and is no longer working (like is this specifically a regression you are seeing)? Can you try running the following from your terminal and see if it works? "C:\Users\Simon Legtenborg\AppData\Local\Programs\Python\Python312\python.exe" c:\Users\Simon Legtenborg\.vscode\extensions\ms-python.python-2025.14.0-win32-x64\python_files\unittestadapter\discovery.py --udiscovery -v -s . -p *test.py you may need to put quotations around the "*test.py". Just wondering if you get the error "UNITTEST ERROR: TEST_RUN_PIPE is not set at the time of unittest trying to send data. Pl...." like I do when I attempt it

    Hi Eleanor,
    I tried this and got the same error as you. I'm now on version 1.104.1
    Thank you for taking a look at the issue!

  11. irenepc commented on Sep 19, 2025

    @irenepc
    Author

    Ok! After getting the latest update (1.104.1), tweaking settings some more, and re-enabling the python environments extension I was able to get some tests to be discovered and testing.

    Thanks everyone for all the clues/ideas!

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

Metadata

Metadata

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