Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VSCode pytest data from WSL generate an error when processed #24811

Open
KinkosPouet opened this issue Feb 12, 2025 · 6 comments
Open

VSCode pytest data from WSL generate an error when processed #24811

KinkosPouet opened this issue Feb 12, 2025 · 6 comments
Assignees
Labels
info-needed Issue requires more information from poster triage-needed Needs assignment to the proper sub-team

Comments

@KinkosPouet
Copy link

Type: Bug

Behaviour

Pytesting through UI doesn't work with WSL extension. An error occures when processing data sent from WSL to VScode :

Steps to reproduce:

  1. Create environnement with hatch (
    hatch env run -e dev test)
  2. Select interpreter in VSCode to point on the venv dir ( hatc
    h env find dev)
  3. Go to testing in VSCode, and play the test.
  4. Test pass without error, but the data is not sent back
Output for Python in the Output panel

Running pytest with args: ['-p', 'vscode_pytest', '--rootdir=/home/user/git/', '/home/user/git/app/tests/test_main.py::test_load_config', '/home/user/git/app/tests/test_main.py::test_get_db_connection_postgresql', '/home/user/git/app/tests/test_main.py::test_get_db_connection_mysql', '/home/user/git/app/tests/test_main.py::test_is_database_empty_postgresql', '/home/user/git/app/tests/test_main.py::test_is_database_empty_mysql', '/home/user/git/app/tests/test_main.py::test_execute_sql_file', '/home/user/git/app/tests/test_main.py::test_process_database_when_empty', '/home/user/git/app/tests/test_main.py::test_process_database_exception', '/home/user/git/app/tests/test_main.py::test_main_process_multiple_databases']
============================= test session starts ==============================
platform linux -- Python 3.11.2, pytest-7.4.3, pluggy-1.5.0
rootdir: /home/user/git/
plugins: mock-3.14.0
collected 9 items

app/tests/test_main.py Plugin error, exception thrown while attempting to send data[vscode-pytest]: unsupported operand type(s) for +=: 'int' and 'NoneType' 
[vscode-pytest] data: 
{"jsonrpc": "2.0", "params": {"cwd": "/home/user/git/", "status": "success", "result": {"/home/user/git/app/tests/test_main.py::test_load_config": {"test": "/home/user/git/app/tests/test_main.py::test_load_config", "outcome": "success", "message": null, "traceback": null, "subtest": null}}, "not_found": null, "error": null}}

(X9)

.           [100%]

============================== 9 passed in 0.05s ===============================
Finished running tests!

Extension version: 2025.0.0
VS Code version: Code 1.97.0 (33fc5a94a3f99ebe7087e8fe79fbe1d37a251016, 2025-02-04T22:41:26.688Z)
OS version: Windows_NT x64 10.0.26100
Modes:
Remote OS version: Linux x64 5.15.167.4-microsoft-standard-WSL2
Remote OS version: Linux x64 5.15.167.4-microsoft-standard-WSL2
Remote OS version: Linux x64 5.15.167.4-microsoft-standard-WSL2

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


languageServer: "Pylance"

testing
• pytestArgs: "<placeholder>"
• pytestEnabled: true

Installed Extensions
Extension Name Extension Id Version
debugpy ms- 2025.0.0
gitlens eam 16.3.0
js-debug ms- 1.97.0
python ms- 2025.0.0
vscode-js-profile-table ms- 1.0.10
vscode-pylance ms- 2025.2.1
System Info
Item Value
CPUs Intel(R) Core(TM) Ultra 9 185H (22 x 3072)
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
skia_graphite: 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) 31.46GB (12.42GB free)
Process Argv --crash-reporter-id bb4a69d2-a4d3-44a5-b62b-19c8f9b82470
Screen Reader no
VM 0%
Item Value
Remote WSL: Debian
OS Linux x64 5.15.167.4-microsoft-standard-WSL2
CPUs Intel(R) Core(TM) Ultra 9 185H (22 x 0)
Memory (System) 15.35GB (13.51GB free)
VM 0%
Item Value
Remote WSL: Debian
OS Linux x64 5.15.167.4-microsoft-standard-WSL2
CPUs Intel(R) Core(TM) Ultra 9 185H (22 x 0)
Memory (System) 15.35GB (13.51GB free)
VM 0%
Item Value
Remote WSL: Debian
OS Linux x64 5.15.167.4-microsoft-standard-WSL2
CPUs Intel(R) Core(TM) Ultra 9 185H (22 x 0)
Memory (System) 15.35GB (13.51GB free)
VM 0%
A/B Experiments
vsliv368cf:30146710
vspor879:30202332
vspor708:30202333
vspor363:30204092
vscod805cf:30301675
binariesv615:30325510
py29gd2263:31024239
c4g48928:30535728
azure-dev_surveyone:30548225
962ge761:30959799
2e7ec940:31000449
pythontbext0:30879054
cppperfnew:31000557
dwnewjupytercf:31046870
nativerepl1:31139838
pythonrstrctxt:31112756
nativeloc1:31192215
iacca1:31171482
5fd0e150:31155592
dwcopilot:31170013
stablechunks:31184530
6074i472:31201624
9064b325:31222308
copilot_t_ci:31222730
jda6j935:31233686

@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Feb 12, 2025
@eleanorjboyd
Copy link
Member

hm looks like it is this line causing the issue bytes_written += __writer.write(segment) from here. Not sure why looks like there is just a problem writing to the named pipe that is open for communication. @karthiknadig any ideas here specifically since this is coming from WSL? I can also add in some more logging, potentially the name-pipe vs use of fifo is being incorrectly selected on WSL?

@github-actions github-actions bot added the info-needed Issue requires more information from poster label Feb 14, 2025
@MartinSalinas98
Copy link

MartinSalinas98 commented Feb 18, 2025

I'm having a very similar issue since fairly recently. I haven't isolated the specific plugin version, but, in my specific case, seems to happen when running (individually and from UI) unitary tests that make use of mock_open, which makes sense if the involved lines contain an open() call.

Some time ago I opened issue #24399, but the behaviour described in that issue seems to have been replaced by the one described here.

@KinkosPouet
Copy link
Author

FYI i did this on a brand new environnement on a new computer.
My code didn't change between my migration from old computer to new one.
I Installed WSL + got my code from my git repo without any changes.

@github-actions github-actions bot removed the info-needed Issue requires more information from poster label Feb 18, 2025
@karthiknadig
Copy link
Member

@eleanorjboyd We need to repro this locally to see what is the error. It is likely a path issue, if the paths are /mnt/c/ style then the vs /tmp then there could be a difference in how we communicate with those. We need to see the logs on how the paths look like. we need to make sure that in WSL scenarios the path does not use Windows mounted folders for pipes.

@github-actions github-actions bot added the info-needed Issue requires more information from poster label Feb 18, 2025
@KinkosPouet
Copy link
Author

@karthiknadig To add some information, in my case, every python files used were in /home/user/, nothing was put in /mnt/c.

@github-actions github-actions bot removed the info-needed Issue requires more information from poster label Feb 18, 2025
@karthiknadig
Copy link
Member

The issue is not with the python files themselves, we use pipes to communicate between VS Code and pytest. When we create the pipes, in WSL they should be created in /tmp and not in any location that is /mnt/. My concern is that it might be creating it in the wrong location, leading to a bad pipe stream.

@github-actions github-actions bot added the info-needed Issue requires more information from poster label Feb 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
info-needed Issue requires more information from poster triage-needed Needs assignment to the proper sub-team
Projects
None yet
Development

No branches or pull requests

4 participants