Skip to content

Please change default tests coverage argument to --cov or allow users to configure it #24973

Open
@xymy

Description

@xymy

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.

Metadata

Metadata

Assignees

Labels

area-testingfeature-requestRequest for new features or functionalityinfo-neededIssue requires more information from posterneeds community feedbackAwaiting community feedbacktriage-neededNeeds assignment to the proper sub-team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions