-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Test discovery with pytest fails, because pytest is run in the base conda env #24122
Comments
Hi! So to confirm, If you run |
Yes.
Yes. |
besides "CONDA_PREFIX":"/Users/guenther/mambaforge","CONDA_PROMPT_MODIFIER":"(base) any other notable settings? @anthonykim1 I am using the createActiveEnvironment command like this, any thoughts on how to produce more logging or what else could be going wrong? If not I can make a change to add additional logging to look at this |
Except for conda, there should be nothing special going in that session. I should not that it's also not the first time that I see this, but I finally got annoyed enough to file an issue. |
Don't think
is related to this issue. @eleanorjboyd It may be the ordering of: vscode-python/src/client/common/process/pythonExecutionFactory.ts Lines 130 to 135 in c314bab
where createActivatedEnvironment just returns on the conda conditional without getting to the desired
in this scneario. This seem the closest to what is "forcing" the use of conda rather than a desired venv?? in this case. |
To the best of my knowledge (from googling all parts of this error message) |
@hamogu Thanks for all the info. I've created plan item for October to further investigate this. #24190 Bit lost on what purest means in:
I have a feeling it may be a typo for pytest, but just wanted to make sure :) |
Yes, that's a typo for "pytest" (or maybe my autocorrect on my phone that knows about "purest" but not about "pytest"). Sorry! |
I am experiencing a similar problem where the test discovery fails. I am working on a project at two locations, on two different machines. In one location the test discovery works, and in other it does not. In both locations, running On the machine where test discovery fails, I have:
The one thing that seems different in vscode python log when opening the tests panel is where the working machine has the command:
The machine which fails has the command:
I have also run sysinternals procmon on both machines when opening the tests window. Both machines launch the python executable in the correct virtual environment, however, the command line parameters and cwd are different. On the machine that works, this command is used:
whereas in the failing case, the venv python.exe is invoked with:
The VSCode version on the working machine is:
And the machine which is failing is:
|
Just merged: #24250 |
It still doesn't work, error output below. Note that the Python interpreter path is set correctly (
|
not work for v2024.17.2024101101 (pre-release) @anthonykim1 |
I can confirm presence of the problem. I tried to use different python extension versions (including prelease too) with no luck. |
@anthonykim1 please open this issue because it is not closed at all |
@eleanorjboyd let's continue on this. |
Hi all, @zljubisic @hamogu, do you guys have a workaround for running the tests in VS Code? Is there anything better than running it from the terminal? |
Still seeing this issue, too, after upgrading the python in my python env from py3.9 to py3.10 Fixed this by re-installing vscode. |
Seems it has been fixed in v2024.17.2024101501 (pre-release) |
Argh, I tried reinstalling, even tried the Insiders version, but I had no luck, this is still happening. |
@jcharlet It is irrelevant with vscode insider. You should switch the python extension to pre-release version. |
Same issue, super annoying |
Hi folks, please give the latest pre-release of Python extension (or v2024.17.2024101501 or higher) a try. |
Type: Bug
Behaviour
Test discovery with pytest fails.
From looking at the output, it seems that pytest is run in my base conda environment, not in the environment for this particular project. My base conda environment has an old, no longer supported Python version and no pytest installed; however, a recent version of python and pytest are installed in the environment that I use for this project and that I want to run the tests in.
I verified that "Python: Select Interpreter ..." is set to the correct environment and this is confirmed by the little icon on the status bar at the bottom right that displays "Python 3.11.7 ('sherpaciao')", where "sherpaciao" is a conda env with pytest. Running pytest in the terminal in that conda env works as extected.
Note that the condo env in the Python output (see full output below) is set to
"CONDA_PREFIX":"/Users/guenther/mambaforge","CONDA_PROMPT_MODIFIER":"(base)
while the warning a few lines down from that addresses the correct conda env:[warning] could not find a pixi interpreter for the interpreter at /Users/guenther/mambaforge/envs/sherpaciao/bin/python
.Steps to reproduce:
I hope that this can be debugged from the console/setting output since it's probably related to some setting that is wrong; I suspect that it's not easy to reproduce.
Diagnostic data
Output for
Python
in theOutput
panel (View
→Output
, change the drop-down the upper-right of theOutput
panel toPython
)Extension version: 2024.14.1
VS Code version: Code 1.93.1 (Universal) (38c31bc77e0dd6ae88a4e9cc93428cc27a56ba40, 2024-09-11T17:20:05.685Z)
OS version: Darwin arm64 23.6.0
Modes:
python.languageServer
setting: DefaultUser Settings
Installed Extensions
System Info
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
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off
A/B Experiments
The text was updated successfully, but these errors were encountered: