microsoft / vscode-python

Python extension for Visual Studio Code
https://aka.ms/pvsc-marketplace
MIT License
4.34k stars 1.19k forks source link

"Run Test with Coverage" should allow omitting files from the report #24309

Closed bersbersbers closed 1 month ago

bersbersbers commented 1 month ago

"Run Test with Coverage" should allow omitting files from the report. Ideally, honor the "omit" setting in the coverage configuration. Some default arguments may be set, such as .venv.

Compare also https://github.com/microsoft/vscode-python/issues/24308.

bersbersbers commented 1 month ago

It seems this can be done using a workaround, namely, by using tool.coverage.run.omit (as opposed to tool.coverage.report.omit, which I tried previously).

[tool.coverage.run]
omit = [
    ".venv/*",
    # https://github.com/nedbat/coveragepy/issues/1392
    "pyscript",
    "shibokensupport/*",
    "signature_bootstrap.py",
]
eleanorjboyd commented 1 month ago

seems related to this: https://github.com/microsoft/vscode-python/issues/24366. Closing this one to group all the issues related to omitting from coverage in one issue.

bersbersbers commented 4 weeks ago

Just for the record: this is a different issue than #24308 IMHO, related to the fact that omission of files can happen in at least two different places.

In this issue, I don't really care which mechanism is used, as long as the files do not appear in the final report in the UI. In fact, the workaround mentioned in https://github.com/microsoft/vscode-python/issues/24309#issuecomment-2413414716 works fine for me. So I am fine with closing this issue.

Just for completeness, in #24308, I care about error handling during the reporting phase, in case a file that exiting during run is missing during report.