Repository navigation
tests are not being discovered #22018
Copy link
Copy link
Closed as not planned
Labels
area-testingbugIssue identified by VS Code Team member as probable bugIssue identified by VS Code Team member as probable buginfo-neededIssue requires more information from posterIssue requires more information from postertriage-neededNeeds assignment to the proper sub-teamNeeds assignment to the proper sub-team
Description
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
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area-testingbugIssue identified by VS Code Team member as probable bugIssue identified by VS Code Team member as probable buginfo-neededIssue requires more information from posterIssue requires more information from postertriage-neededNeeds assignment to the proper sub-teamNeeds assignment to the proper sub-team
Activity
gbajson-area22 commentedon Sep 18, 2023
This started to work when I opened my project from the realpath.
I have a symlink to project dirs in my home dir and in that case it doesn't work.
VS Code file opened as:
/home/gbajson/Sync/area22/vox2/vox.code-workspace-- tests are not discoveredVS Code file opened as:
/storage/amoje/Sync/area22/vox2/vox.code-workspace-- tests are discoveredeleanorjboyd commentedon Sep 18, 2023
Hello! Could you try this on the rewrite of the testing infrastructure to see if it occurs here? You can do so by adding this setting to your users
settings.json"python.experiments.optInto": ["pythonTestAdapter"].You can confirm you have the rewrite enabled by setting
"python.analysis.logLevel": "Trace",in your user settings then checkExperiment 'pythonTestAdapter'is active in your python logs.Let me know if the rewrite fixes your issue. Thanks!
kbokh commentedon Sep 20, 2023
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
eleanorjboyd commentedon Sep 20, 2023
Can you clarify what your setup is with the two root paths? Are those on the same computer? I have been trying to repro this symlink issue but have been unable to. If you are able to review the steps I took here and let me know how your setup differs that would be very helpful! #21373
rohanaras commentedon Sep 25, 2023
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:
rohanaras commentedon Sep 25, 2023
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
eleanorjboyd commentedon Oct 4, 2023
Hi Rohan Aras (@rohanaras) could you try this on the rewrite? It looks from the output you are still on the older code.
To try it yourself, add this setting to your users
settings.json"python.experiments.optInto": ["pythonTestAdapter"].You can confirm you have the rewrite enabled by setting
"python.analysis.logLevel": "Trace",in your user settings then check forExperiment 'pythonTestAdapter'is active in your python logs.Let me know if the rewrite fixes your issue. Thanks!
AdrianB-sovo commentedon Oct 11, 2023
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)"
21 remaining items
eleanorjboyd commentedon Feb 26, 2024
Hello! This bug should be fixed and on vscode insiders! The release to vscode stable will be out by the end of the week. Please let me know if you try it on insiders or stable when it comes out and still doesn't work and I can investigate your specific issue further.
eleanorjboyd commentedon Apr 15, 2024
Hi Alan Silva (@alanwilter), just got back from vacation and unlocked this. Could you describe the issue you are still seeing? Is it still the same setup as this? I have been testing it in a few scenarios and it has been working for me recently but I must still be missing a scenario. Thanks
eleanorjboyd commentedon Apr 15, 2024
Also can you send over your pytest args when you describe your setup? I think this could be contributing if you already specific a cwd or rootdir but I would have to check further.
eleanorjboyd commentedon Apr 30, 2024
Hello again! Recently I have merged this PR which was very similar to your symlink issue. I think that merge should resolve this but please let me know if not and I can keep investigating. Thanks!