vscode-python: tests are not being discovered
Type: Bug
Tests for python project are not appearing in VS Code.
In the terminal output I foud the command that is executed. This command returns proper tests
$ ~/.cache/pypoetry/virtualenvs/vox-7_rKBGgW-py3.11/bin/python ~/.vscode/extensions/ms-python.python-2023.16.0/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir . -s --cache-clear .
[{"rootid": ".", "root": "/storage/amoje/Sync/area22/vox2", "parents": [{"id": "./src", "kind": "folder", "name": "src", "parentid": ".", "relpath": "./src"}, {"id": "./src/vox", "kind": "folder", "name": "vox", "parentid": "./src", "relpath": "./src/vox"}, {"id": "./src/vox/test_main.py", "kind": "file", "name": "test_main.py", "parentid": "./src/vox", "relpath": "./src/vox/test_main.py"}], "tests": [{"id": "./src/vox/test_main.py::test_read_main", "name": "test_read_main", "source": "./src/vox/test_main.py:13", "markers": [], "parentid": "./src/vox/test_main.py"}, {"id": "./src/vox/test_main.py::test_comedy_tom_hanks", "name": "test_comedy_tom_hanks", "source": "./src/vox/test_main.py:20", "markers": [], "parentid": "./src/vox/test_main.py"}]}]
VS Code version: Code 1.82.2 (abd2f3db4bdb28f9e95536dfa84d8479f1eb312d, 2023-09-14T05:51:20.981Z) OS version: Linux x64 6.2.0-32-generic snap Modes:
System Info
| Item | Value |
|---|---|
| CPUs | AMD Ryzen 9 5900X 12-Core Processor (24 x 2200) |
| 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, 1, 1 |
| Memory (System) | 62.71GB (51.43GB free) |
| Process Argv | –no-sandbox --force-user-env --unity-launch --crash-reporter-id cccdcc23-b3ed-4860-8b66-fadc67e8d915 |
| Screen Reader | no |
| VM | 0% |
| DESKTOP_SESSION | ubuntu |
| XDG_CURRENT_DESKTOP | Unity |
| XDG_SESSION_DESKTOP | ubuntu |
| XDG_SESSION_TYPE | x11 |
Extensions (43)
| Extension | Author (truncated) | Version |
|---|---|---|
| terraform | 4op | 0.2.5 |
| vscode-markdownlint | Dav | 0.51.0 |
| gitlens | eam | 14.3.0 |
| remotehub | Git | 0.60.0 |
| go | gol | 0.39.1 |
| terraform | has | 2.27.2 |
| vscode-python-timeit | Has | 1.3.8 |
| file-downloader | min | 1.0.12 |
| prettify-json | moh | 0.0.3 |
| black-formatter | ms- | 2023.4.1 |
| isort | ms- | 2023.10.1 |
| pylint | ms- | 2023.6.0 |
| python | ms- | 2023.16.0 |
| vscode-pylance | ms- | 2023.9.10 |
| jupyter | ms- | 2023.8.1002501831 |
| jupyter-keymap | ms- | 1.1.2 |
| jupyter-renderers | ms- | 1.0.17 |
| vscode-jupyter-cell-tags | ms- | 0.1.8 |
| vscode-jupyter-slideshow | ms- | 0.1.5 |
| remote-containers | ms- | 0.309.0 |
| remote-ssh | ms- | 0.106.4 |
| remote-ssh-edit | ms- | 0.86.0 |
| remote-wsl | ms- | 0.81.3 |
| vscode-remote-extensionpack | ms- | 0.24.0 |
| azure-repos | ms- | 0.36.0 |
| remote-explorer | ms- | 0.4.1 |
| remote-repositories | ms- | 0.38.1 |
| remote-server | ms- | 1.4.3 |
| remote-kubernetes | Okt | 0.4.10 |
| vscode-circular-dependencies-finder | ole | 1.1.0 |
| r-debugger | RDe | 0.5.4 |
| java | red | 1.22.1 |
| vscode-yaml | red | 1.14.0 |
| markdown-preview-enhanced | shd | 0.7.9 |
| intellicode-api-usage-examples | Vis | 0.2.8 |
| vscodeintellicode | Vis | 1.2.30 |
| keyoti-changeallendoflinesequence | vs- | 0.0.3 |
| vscode-java-debug | vsc | 0.54.0 |
| vscode-java-dependency | vsc | 0.23.1 |
| vscode-java-pack | vsc | 0.25.14 |
| vscode-java-test | vsc | 0.39.1 |
| vscode-maven | vsc | 0.42.0 |
| markdown-all-in-one | yzh | 3.5.1 |
A/B Experiments
vsliv368cf:30146710
vsreu685:30147344
python383:30185418
vspor879:30202332
vspor708:30202333
vspor363:30204092
vslsvsres303:30308271
vserr242:30382549
pythontb:30283811
vsjup518:30340749
pythonptprofiler:30281270
vshan820:30294714
vstes263:30335439
vscod805cf:30301675
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
vsaa593cf:30376535
pythonvs932:30410667
vsclangdc:30486549
c4g48928:30535728
dsvsc012cf:30540253
pynewext54:30695312
azure-dev_surveyone:30548225
vscccc:30803845
282f8724:30602487
89544117:30613380
showlangstatbar:30737416
962ge761:30835153
03d35959:30757346
pythonfmttext:30731395
fixshowwlkth:30771522
showindicator:30805244
pythongtdpath:30769146
i26e3531:30792625
pythonnosmt12:30797651
pythonidxpt:30805730
pythonnoceb:30805159
asynctok:30821568
dsvsc013:30795093
dsvsc014:30804076
diffeditorv1:30821571
dsvsc015:30829745
About this issue
- Original URL
- State: closed
- Created 9 months ago
- Reactions: 3
- Comments: 27 (14 by maintainers)
So I used you repo, it’s somewhat worked but I got this message (just part of it):
Then I went to my repo. My project
settings.jsonhas:But once I copied your local
settings.jsonsomething happened, logs showed something, Explorer as well:your
settings.json:However, it’s still useless as nothing happens when I click on play test button.
I also use
pyproject.tomlwithBut even commenting that line it still have the same problem.
After some try-and-error I found out that your new Test rewrite don’t like
"-c", "/dev/null"args in mysettings.jsonHowever, this is there to avoid using the set given in
pyproject.toml.Then, I remembered the “symlink” issue and when I used the realpath (even if having a whitespace)… it worked!
Bottomline:
pyproject.tomlis not the issue, I put back my settings for pytest"-c", "/dev/null"from"python.testing.pytestArgs"For those using WSL on Windows, the “python.experiments.optOutFrom” will not be supported on your local user settings, you should use the remote user settings. ctrl + shift + p → “Preferences: Open Remote Settings (JSON)”
Oh and one more thing: the output of
conda run -n default --no-capture-output python ~/.vscode-server/extensions/ms-python.python-2023.16.0/pythonFiles/get_output_via_markers.py ~/.vscode-server/extensions/ms-python.python-2023.16.0/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir . -s --cache-clear .appears to list all tests when I run the command myself from the symlink version of the repositories
Can confirm that I have a similar issue as well.
My file paths look like this:
~/repos/[git-repo-name]where I have the symlink
repos -> /mnt/data_science/rohana/repos,~is/home/rohana1,and
/mnt/data_scienceis a nfs file share.Opening any repository from
/home/rohana/reposresults in no tests being discovered, whereas all tests are discovered when I open any repository from/mnt/data_science/rohana/reposRunning pytest from the terminal works in both places.
Tried doing this, couldn’t figure out how to confirm that the rewrite was working (should
Experiment 'pythonTestAdapter'have shown up underOUTPUT > Python?), but it didn’t seem to fix the issue.System information:
The same problem with a symlink. Linux (EndeavourOS), vscode 1.82.2, a python 3.11 env managed by the poetry. The unittest can find tests but the pytest cannot. Pytest works well with a realpath