Description
Currently this extension will add --cov=.
by default when tests with coverage. According to pytest-cov's docs:
If you use the --cov=something option (with a value) then coverage’s source option will also get overridden. If you have multiple sources it might be easier to set those in .coveragerc and always use --cov (without a value) instead of having a long command line with --cov=pkg1 --cov=pkg2 --cov=pkg3 ....
so this will override my coverage config file and lead to include unwanted files in my coverage report.
To solve it, this extension's docs guide users to configure python.testing.pytestArgs
:
When the pytest argument --cov exists in python.testing.pytestArgs, the Python extension will make no additional edits to coverage args, to allow your customizations to take effect. If there is no --cov argument found, the extension will add --cov=. to the pytest args prior to run to enable coverage at the workspace root.
In my opinion, this is not a good behavior. Beacause python.testing.pytestArgs
doesn't distinguish tests and tests with coverage. Since vscode give us separate buttons for them, it's better to give separate pytest arguments too.
I think --cov
maybe a better default behavior, and just guide users to configure coverage for file discovery.
A new option likes python.testing.pytestCovArgs
is a good idea to allow more customize coverage behavior.