Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

Copy link
Copy link
Open
@xymy

Description

@xymy
Issue body actions

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 functionalityRequest for new features or functionalityinfo-neededIssue requires more information from posterIssue requires more information from postertriage-neededNeeds assignment to the proper sub-teamNeeds 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

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.