Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide separate configurations for running tests with coverage #24865

Open
thomthom opened this issue Mar 5, 2025 · 1 comment
Open

Provide separate configurations for running tests with coverage #24865

thomthom opened this issue Mar 5, 2025 · 1 comment
Assignees
Labels
area-testing feature-request Request for new features or functionality

Comments

@thomthom
Copy link

thomthom commented Mar 5, 2025

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=."
}
@thomthom thomthom added the feature-request Request for new features or functionality label Mar 5, 2025
@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Mar 5, 2025
@eleanorjboyd eleanorjboyd self-assigned this Mar 5, 2025
@eleanorjboyd
Copy link
Member

eleanorjboyd commented Mar 5, 2025

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

@eleanorjboyd eleanorjboyd added area-testing and removed triage-needed Needs assignment to the proper sub-team labels Mar 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-testing feature-request Request for new features or functionality
Projects
None yet
Development

No branches or pull requests

2 participants