Repository navigation
Cannot discover tests anymore, python executable not used #22618
Copy link
Copy link
Closed
Labels
area-testinginfo-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
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:
- Load a project previously having tests discovered.
- 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.languageServersetting: Default
Output for Python in the Output panel (View→Output, 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
Reactions are currently unavailable
Metadata
Metadata
Labels
area-testinginfo-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
kristiandupont commentedon Dec 11, 2023
I don't know if this is the same issue, but I get this output:
This started happening right after I upgraded VSCode today. I wonder if it introduced stricter roles for subprocesses?
johansmolinski commentedon Dec 11, 2023
My issue does not seem to be related to access rights.
Some updates. I rebooted my computer, because why not, and the issue changed a bit. Now at least it tries to scan for tests, but finds 0. However, now the tests can be run individually from the editor (the run test arrow pops up at the test definition code). By the way, from the terminal I can still run the test suite using
python -m unittest.AndreasHaure commentedon Dec 11, 2023
Have encountered the same exact issue after the latest update of vscode. It looks like the discovery command that vscode is executing is wrong. From the terminal I can see it is executing
However it works if I change that to the following and run it manually in my terminal:
eff917 commentedon Dec 11, 2023
Happened to me too, downgrading Python extension to 2023.20 solves the issue, so bug is in 2023.22 extension version.
Python extensions tested:
edit: If we can provide any logs, please let us know
danibishop commentedon Dec 11, 2023
Can confirm the same behaviour that Peter Felber (@eff917) mentions. Downgrading is the easiest way to mitigate, it seems.
bricker commentedon Dec 12, 2023
I had a similar problem today with pytest. No errors in the Output console though. It just said this:
But nothing happened.
To work around it, I disabled the new test adapter experiment by adding this to my VSCode user settings:
After adding this (and restarting VSCode), Python tests were discovered correctly. And, I can't explain why, but I went back and removed that setting and test discovery is now working with the new test adapter. 🤷
nmost commentedon Dec 12, 2023
This is also happening for me on Sonoma 14.2. Downgrading the Extension to 2023.20 fixed the issue
M3ssman commentedon Dec 12, 2023
Editing
python.experiments.optOutFromdoesn't work as suggested (Ubuntu 20.04 LTS, Python 3.8.13, /ms-python.python-2023.22.0) but produces the outputdanielWagnerr commentedon Dec 12, 2023
Same problem as Kristian Dupont (@kristiandupont) here
eleanorjboyd commentedon Dec 12, 2023
Hello everyone, sorry for the delay and lets figure out the problem here. It seems that
"python.experiments.optOutFrom": ["pythonTestAdapter"]this was a fix for some but not all so given this we have two different issues, one which is impacted by the experiment being on and one which does not depend on the experiment.Johan Smolinski (@johansmolinski) with
Error[vscode-unittest]: TEST_PORT is not set. TEST_UUID = None Error: no uuid provided or parsed.What happens is we set an env var to store the value of the UUID and PORT for testing and spin up a subprocess with these env vars to pass this information. Can you check to see if you override or clear environment variables during testing?Kristian Dupont (@kristiandupont), it seems you are running the old discovery, can you please try and run the new testing experiment. Your logs reference
/pythonFiles/testing_tools/run_adapter.pywhich is a file only used in the old code. You could try opting into the experiment explicitly ("python.experiments.optInto": ["pythonTestAdapter"]) but everyone should have the experiment so I am not sure why you are still seeing the old code. I would check to see if you are opted out from all experiments in your workspace or user settings.Johan Smolinski (@johansmolinski), can you include logs from this run "Now at least it tries to scan for tests, but finds 0". Please set log level to trace via the command palette.
Andreas Haure (@AndreasHaure) and Uwe Hartwig (@M3ssman) same as Kristian Dupont (@kristiandupont), try to switch to new experiment.
Peter Felber (@eff917), Nick Mostowich (@nmost), and Dani Ramírez (@danibishop) if you could provide logs that would be great, if you could also set log level to trace via the command palette.
Bryan Ricker (@bricker), interesting a re-start worked, let me know if you see this behavior pop up again.
Thanks everyone for engaging on this issue!
smoy commentedon Dec 12, 2023
I reproduce the same symptom and I found what mades a difference for me is how I open vscode for my project. If I open VSCode first, and then select the pre-existing virtualenv, I can make test discovery to work. However, my typical using the /usr/local/bin/code (already in my path, so i just code .)
code ., the test discovery will consistent not work.Like others, if i revert to earlier vscode python extension
2023.20.0, test discovery works normally.More specifically. before I use
code ., i am already inside a virtualenv, i think this affects the environment detection. If i usecode .outside of an already active virtual environment, I am able see test discovery normally.eleanorjboyd commentedon Dec 12, 2023
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)7 remaining items
Revert "Remove old code for folder support in interpreter path settin…
dnwillia commentedon Dec 13, 2023
Eleanor Boyd (@eleanorjboyd) I have the issues described here and I am doing what you say.
cdinto my project directory, activate my virtual environment and then typecode .on the command line, but the same thing happens if I start VS code from the Applications folder and pick the project directory. In the latter case when I hit F1 and "Select Python Interpreter" I can see that it has automatically selected "./venv" rather than "./venv/bin/python" and when I update it to the latter it seems to be working. This is with 2023.22.0.laipz8200 commentedon Dec 13, 2023
This update solved my problem.
stuartmaxwell commentedon Dec 13, 2023
This fixed the issue for me. thanks.
roybeny commentedon Dec 13, 2023
Stuart Maxwell (@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!
firatkizilirmakk commentedon Dec 13, 2023
this worked for me as well.
thanks.
Revert "Remove old code for folder support in interpreter path settin…
eff917 commentedon Dec 13, 2023
Also confirmed,
ms-python.python-2023.23.13471011solved discovery problems.eleanorjboyd commentedon Dec 14, 2023
closing as the point release contains the fix to this issue. Please comment if you are still experiencing problems even on the point release. Thanks