microsoft / vscode-python

Python extension for Visual Studio Code
https://aka.ms/pvsc-marketplace
MIT License
4.25k stars 1.15k forks source link

Test discovery errors out when navigating to the test panel (pytest) #23474

Closed vigneshmanick closed 1 month ago

vigneshmanick commented 1 month ago

Behaviour

When navigating to the test explorer for a python project with pytests, the panel errors out.

Expected vs. Actual

test explorer erros out vs showing the tests

Steps to reproduce:

Navigate to the test explorer in a python project with pytests enabled

Diagnostic data

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

``` 2024-05-24 10:57:23.117 [info] Discover tests for workspace name: test_proj - uri: /scratch/user/test_proj 2024-05-24 10:57:23.141 [info] > /scratch/user/myprograms/miniconda3/bin/conda run -p ./.pixi/envs/default --no-capture-output python /scratch/user/VSCode-linux-x64/data/extensions/ms-python.python-2024.2.1/pythonFiles/get_output_via_markers.py /scratch/user/VSCode-linux-x64/data/extensions/ms-python.python-2024.2.1/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir . -s --cache-clear tests 2024-05-24 10:57:23.141 [info] cwd: . 2024-05-24 10:57:24.814 [error] Error discovering pytest tests: [n [Error]: The (legacy) plugin 'activate' is trying to override the built-in command with the same name, which is not allowed. Please uninstall the plugin to stop seeing this error message. at ChildProcess. (/scratch/user/VSCode-linux-x64/data/extensions/ms-python.python-2024.2.1/out/client/extension.js:2:226040) at Object.onceWrapper (node:events:628:26) at ChildProcess.emit (node:events:513:28) at maybeClose (node:internal/child_process:1091:16) at Socket. (node:internal/child_process:449:11) at Socket.emit (node:events:513:28) at Pipe. (node:net:322:12)] ```

User Settings

``` condaPath: "/scratch/user/myprograms/miniconda3" languageServer: "Pylance" testing • pytestArgs: • pytestEnabled: true ```

System information

CPUs    Intel(R) Xeon(R) Gold 6254 CPU @ 3.10GHz (8 x 3092)
GPU Status  2d_canvas: enabled canvas_oop_rasterization: disabled_off 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: disabled_software vulkan: disabled_off webgl: enabled webgl2: enabled webgpu: disabled_off
Load (avg)  0, 0, 0
Memory (System) 62.76GB (56.07GB free)
Process Argv    --no-sandbox .
Screen Reader   no
VM  100%
karthiknadig commented 1 month ago

@vigneshmanick It seems like you are using a older version of the extension, can you please update?

vigneshmanick commented 1 month ago

Thanks for the response.

I am stuck on vscode version 1.85.2 due to glibc requirements (It's a RHEL 7.9 Machine) and i guess the python extension is also tied to that?. When i run check for updates for extension i get the message that it's upto date.

Is this is a known issue in the python extension that has been fixed in a newer version?

eleanorjboyd commented 1 month ago

apologies for the delay! I will get to this shortly!

eleanorjboyd commented 1 month ago

Hello! From your logs it seems like you are not on the testing rewrite which may fix this issue. Please switch over and let me know if this helps!

To switch, add this setting to your users settings.json "python.experiments.optInto": ["pythonTestAdapter"]. You can confirm you have the rewrite enabled by using the command palette to set "developer set log level" to "trace" then checking for Experiment 'pythonTestAdapter' is active in your python logs.

vigneshmanick commented 1 month ago

Thanks for the response, i can confirm that with changing the pythonTestAdapter setting the tests are now recognized properly. I can now see all the tests as before.

eleanorjboyd commented 1 month ago

great!