Skip to content

Provide separate configurations for running tests with coverage #24865

Open

Description

Following up on conversion in this thread:
#22827 (comment)

I found that when I had --cov argument I wasn't able to debug my tests. No breakpoints would catch. That's why I was looking for separate arguments between doing a normal test run and running tests with coverage.

Not sure why the debugger wouldn't break when --cov was used though, bug?

I keep running into this.

I would to configure the coverage arguments when running tests with coverage so I can narrow down the scope of what is checked for coverage. But I don't want to add arguments that enables coverage in normal test runs. (Which conflicts when I'm debugging tests.)

#22827 (comment)

I just tested out "Run With Coverage" on my python project. I have the sources for my app in a sub-folder so my coveragerc contains:

[run]
source = myapp
omit = myapp/tests/*

However, when I use Run With Coverage it appear to inject --cov=. which in turn overrides my source config. The result of that is that coverage picks up python all python files from the root of my project, not just limited to ./myapp.

I've not found any way around for this. Is it a bug? Or have I missed a configuration?

What I think would work is a configuration setting for what vscode-python injects when running with coverage. The default is --cov=., but if we can override that it would help.

Maybe something like

{
  "python.testing.pytestCoverageArgs": "--cov=mysources", // Defaulting to "--cov=."
}

Activity

  1. eleanorjboyd commented on Mar 5, 2025

    @eleanorjboyd
    Member

    added this request to an overarching issue about custom configs for testing: #21845

  2. eleanorjboyd commented on Jun 30, 2025

    @eleanorjboyd
    Member

    Courtney Webster (@cwebster-99) since we haven't had movement on our custom configs for testing, should we consider just adding this seperately?

  3. github-actions commented on Dec 8, 2025

    @github-actions

    Thanks for the feature request! We are going to give the community 60 days from when this issue was created to provide 7 👍 upvotes on the opening comment to gauge general interest in this idea. If there's enough upvotes then we will consider this feature request in our future planning. If there's unfortunately not enough upvotes then we will close this issue.

  4. james-crow commented on Dec 24, 2025

    @james-crow

    This gets my vote, would be great to have this flexibility, and is particularly useful in monorepo environments.

  5. weg-jr commented on Aug 13, 2026

    @weg-jr

    I ran into this as well using pixi and either my coverage includes the entire pixi environment which takes forever or I override cov in my settings.json and then my regular tests now invoke coverage every time which also takes forever

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions