vscode-python: Cannot discover tests anymore, python executable not used

Type: Bug

Behaviour

Expected vs. Actual

Expected: Clicking the tests icon should discover tests. Actual: No tests have been found in this workspace yet.

Steps to reproduce:

  1. Load a project previously having tests discovered.
  2. Click the Tests icon.

Diagnostic data

  • Python version (& distribution if applicable, e.g. Anaconda): 3.11.6
  • Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Venv
  • Value of the python.languageServer setting: Default
Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

python /Users/johan/.vscode/extensions/ms-python.python-2023.22.0/pythonFiles/unittestadapter/discovery.py --udiscovery -v -s ./src -p test_*.py

and if I run that myself in the terminal, I get:

Error[vscode-unittest]: TEST_PORT is not set.  TEST_UUID =  None
Error: no uuid provided or parsed.
Error sending response: [Errno 61] Connection refused
Request data: Content-Length: 42
Content-Type: application/json
Request-uuid: 

{"command_type": "discovery", "eot": true}

User Settings


languageServer: "Pylance"

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

Extension version: 2023.22.0 VS Code version: Code 1.85.0 (Universal) (af28b32d7e553898b2a91af498b1fb666fdebe0c, 2023-12-06T18:18:04.614Z) OS version: Darwin arm64 23.1.0 Modes:

System Info
Item Value
CPUs Apple M1 Max (10 x 24)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
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
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
Load (avg) 5, 5, 6
Memory (System) 64.00GB (0.05GB free)
Process Argv . --crash-reporter-id f7b7518c-4fd8-4a0b-b95d-1c10ff2f756b
Screen Reader no
VM 0%
A/B Experiments
vsliv368:30146709
vsreu685:30147344
python383cf:30185419
vspor879:30202332
vspor708:30202333
vspor363:30204092
vstes627:30244334
vslsvsres303:30308271
vserr242:30382549
pythontb:30283811
vsjup518:30340749
pythonptprofiler:30281270
vshan820:30294714
vstes263:30335439
vscod805:30301674
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
vsaa593cf:30376535
pythonvs932:30410667
py29gd2263:30899288
vscaat:30438848
vsclangdc:30486549
c4g48928:30535728
dsvsc012cf:30540253
azure-dev_surveyone:30548225
2e4cg342:30602488
89544117:30613380
2i9eh265:30646982
showlangstatbar:30737416
962ge761:30917236
fixshowwlkth:30771522
showindicator:30805244
pythongtdpath:30769146
i26e3531:30792625
welcomedialogc:30910334
pythonnosmt12:30797651
pythonidxpt:30866567
pythonnoceb:30805159
asynctok:30898717
dsvsc013:30795093
dsvsc014:30804076
dsvsc015:30845448
pythontestfixt:30902429
pyreplss1:30897532
pythonmypyd1:30879173
pythoncet0:30885854
pythontbext0:30879054
accentitlementsc:30887149
dsvsc016:30899300
dsvsc017:30899301
dsvsc018:30899302
aa_t_chat:30882232
dsvsc019:30917259

About this issue

  • Original URL
  • State: closed
  • Created 7 months ago
  • Reactions: 9
  • Comments: 23 (4 by maintainers)

Commits related to this issue

Most upvoted comments

Hi everyone, we’ve deployed a fix to the pre-release version. Please give it a try and let us know if it helps.

image

Happened to me too, downgrading Python extension to 2023.20 solves the issue, so bug is in 2023.22 extension version.

OS: Arch linux
VSCode: 1.85.0
Python : 3.12.0 with poetry venv
Pytest: 7.4.3

Python extensions tested:

  • 2023.22 - no discovery (pytest works in console)
  • 2023.20 - works
  • 2023.18 - works

edit: If we can provide any logs, please let us know

I don’t know if this is the same issue, but I get this output:

2023-12-11 09:28:38.822 [error] Error discovering pytest tests:
 Error: spawn /Users/kristiandupont/repositories/[redacted]/venv EACCES
    at Process.ChildProcess._handle.onexit (node:internal/child_process:283:19)
    at onErrorNT (node:internal/child_process:476:16)
    at processTicksAndRejections (node:internal/process/task_queues:82:21) {
  errno: -13,
  code: 'EACCES',
  syscall: 'spawn /Users/kristiandupont/repositories/[redacted]/venv',
  path: '/Users/kristiandupont/repositories/[redacted]/venv',
  spawnargs: [
    '/Users/kristiandupont/.vscode/extensions/ms-python.python-2023.22.0/pythonFiles/testing_tools/run_adapter.py',
    'discover',
    'pytest',
    '--',
    '--rootdir',
    '/Users/kristiandupont/repositories/[redacted]',
    '-s',
    '--cache-clear',
    'api/tests/'
  ]
}

This started happening right after I upgraded VSCode today. I wonder if it introduced stricter roles for subprocesses?

Hi everyone, we’ve deployed a fix to the pre-release version. Please give it a try and let us know if it helps.

image

This fixed the issue for me. thanks.

Hello everyone, I am able to repro the issue and am in the process of narrowing down what commit in release 2023.22.0 is causing the issue. I will send updates in this issue.

The issue is the wrong path is put for the python executable: expected ./.venv/bin/python -m pytest -p vscode_pytest --collect-only . (which works) actual ./.venv -m pytest -p vscode_pytest --collect-only . (which doesn’t work)

Also confirmed, ms-python.python-2023.23.13471011 solved discovery problems.

Hi everyone, we’ve deployed a fix to the pre-release version. Please give it a try and let us know if it helps.

image

this worked for me as well.

thanks.

@stuartmaxwell - works for me. The “Testing” explorer was first still at the “No tests were found…”, so I thought it didn’t work but after a few seconds it loaded the tests.

thanks!

This is also happening for me on Sonoma 14.2. Downgrading the Extension to 2023.20 fixed the issue

Can confirm the same behaviour that @eff917 mentions. Downgrading is the easiest way to mitigate, it seems.