-
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
Pytest code coverage does not show up #24241
Comments
It seems like the extensions does not see that pytest-cov is installed in that case. But I do not know how I can check what the reason for this behaviour is. Running pytest with the |
I can confirm this behavior (tests run, but no coverage is generated). I'm also seeing the same behavior when running VSCode+Python natively on Windows. |
Also seeing this behavior on Mac. Using conda for virtual environment |
Hi! From your logs it looks like you aren't on the testing rewrite which is required. Could you update to our rewrite and try again? You can do so adding this setting to your users settings.json "python.experiments.optInto": ["pythonTestAdapter"]. Then you can confirm its enabled by finding Experiment 'pythonTestAdapter' is active in your python logs. If you are unable to see the log for the experiment change your log level to trace and it should show up. |
Ah, the |
For clarity I have created a PR so the button is only surfaced on the rewrite where coverage is supported: #24249. |
I will check tomorrow if this also fixes the issue for me. Did I miss this information about the required experiment in the Docs? The release notes and also the Documentation do not mention that the setting is required. And why did it work on my Linux machine out of the box? Hiding the button is one way to handle it, if this is clearly documented I do not see an issue. The other option would be to present the user with a hint how the feature can be enabled. For me that would have been the best options, otherwise I would have opened an issue that the button is missing. |
yes we will add a doc update to clarify cc @cwebster-99 |
I can confirm that the experiment also fixes the issue for me. I can now also explain why it worked on my linux machine. The experiment has been active there as part of an A/B test. If I disable the A/B tests for the python extensions it also does not work here. Therefore discussions about the platform have not been based on the platform but rather random on the enabled A/B test. The issue is therefore resolved for me, but I think for closing this issue it is at least required to add this to the documentation, otherwise other users will also be confused. |
@eleanorjboyd just curious, is there a timeline when "pythonTestAdapter" will be enabled by default? |
Hi @ivan-toriya, yes we want to get it to default (as it also makes it more maintainable) we are waiting until one final issue with named pipe communication is finished as this causes the new experience to break for some users. |
Even after adding the setting to my json config file I can't see the experiment active in the logs (I changed the log level) nor does the coverage show up. I'm on mac, any ideas? |
Hi @alspadoni can you try running the command "Python: clear cache and reload window"? (Sorry about the delay as well) |
I've tried adding the {
"python.testing.pytestArgs": [
"core"
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
"python.experiments.optInto": [
"pythonTestAdapter",
],
} |
Can you put the experiment opt into setting in your user settings? Then you can confirm its enabled by finding Experiment 'pythonTestAdapter' is active in your python logs. If you are unable to see the log for the experiment change your log level to trace and it should show up. To set to trace use theDeveloper: set log level command in the command palette. Thanks |
@eleanorjboyd It is present in my user settings also. There is nothing present in logs, images attached below. |
Here is my entire python log history:
|
yes so this shows you are not on the rewrite |
Type: Bug
Behaviour
Clicking on the Run Tests with Coverage button does not have any effect. No coverage data is generated.
As you can see in the output no option enabling coverage is also passed to pytest.
I use VScode with WSL. I tested the same on a native Linux Computer and it worked as expected.
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.16.0
VS Code version: Code 1.94.0 (d78a74bcdfad14d5d3b1b782f87255d802b57511, 2024-10-02T13:08:12.626Z)
OS version: Windows_NT x64 10.0.19045
Modes:
Remote OS version: Linux x64 5.15.153.1-microsoft-standard-WSL2
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: