-
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
Python Test uses incorrect python environment #24087
Comments
Hi! I am seeing an error arise before you get the the actual testing. This error:
Can you check any environment variables you are putting in? Through a .env file, vscode settings or otherwise. It seems like it can't parse something and that is why it cannot start up the environment to then run tests |
Good catch, but unfortunately, that issue (I was printing out something in my Powershell profile on Powershell startup that it was trying to parse in addition to env variables) does not seem related. I fixed it and restarted VS code and even my machine and I still get the same issue where it appears to be using the default
Actually, I don't think it is using it for test discovery (seems to be using just the normal path or something?):
|
I turned on the
I could be reading it wrong, but it seems like it is assuming that when it runs
If that were the case a simple fix to prepend Even if you don't plan to do that for priority reasons, where is this code (that runs |
And for confirmation it is using the system default python, I removed the
|
I believe I am facing the same problem. However, it does not occur anymore when I switch the |
That did it! Test collection and execution are back to working like normal. Thank you @leiterrl! I never would have thought to try that. @eleanorjboyd the above solved my issue, but it would be interesting to know if there is a plan to make it so |
I have the same problem as the above, and adding My selected python interpreter in VSCode in my workspace is (and has been for multiple years) a conda environment, but I noticed as of today that VSCode's test runner seemed to be using a
|
I had the same issue — I believe it (python.locator) was changed after an update to vsstudio. |
@karthiknadig any ideas about the correlation between the native locator stuff? |
@eleanorjboyd Not really sure why this is happening. We can look at the API and see if there is a difference is why it misses selecting the expected repo. We might need a repro for this to diagnose further. |
It seems that it's taking a prefix that has |
I just tested v2024.16.0 and the problem still persists for me. Unfortunately my work machine is pretty locked down so I can't share logs easily. @logar16 maybe you can also check it on your side? |
Hey @eleanorjboyd, this issue might need further attention. @logar16, you can help us out by closing this issue if the problem no longer exists, or adding more information. |
Type: Bug
Behaviour
My tests no longer show up due to a "pytest Discovery Error". I check the output (thanks for the link) and I see that it tries to use my environment, but then it outputs a warning and tries running pytest with the default python installed on the machine!
I can tell it is the default because in an earlier test I saw it was using the C:/Python311
which doesn't have pytest-cov installed. I have pytest-cov installed in my conda environment.
When I run the command it says it is using
That command fails when according to the Python Output, but it works just fine if I manually run it in my conda environment. When I manually run the command in the default python env (
C:\Python311
or whatever), it has the same error output as the python-tests about not accepting coverage-related input arguments.I don't know why this suddenly started to break?
The problematic part of the output (as far as I can tell):
Is it failing to find
pixi
and that breaks something that forces it to default topython
instead ofconda run -n Autobot python
?I tried updating the python extension and pytest, but I get the feeling the issue is in the extension since it is using the wrong python environment.
Steps 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.0
VS Code version: Code 1.93.0 (4849ca9bdf9666755eb463db297b69e5385090e3, 2024-09-04T13:02:38.431Z)
OS version: Windows_NT x64 10.0.22631
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
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off
A/B Experiments
The text was updated successfully, but these errors were encountered: