coveragepy / coveragepy/coveragepy
No access to target directory in configuration file breaking integration with IDE
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 3.4k
- Forks
- 525
- Avg merge
- 18h 27m
- Merged PRs (30d)
- 6
Description
Originally reported by Joshkitchens27 (Bitbucket: Joshkitchens27, GitHub: Unknown)
I'm trying to set up my working environment using Visual Studio Code, and have run into an issue with Coverage that I can't find a solution to.
I'm trying to integrate automation of my unit tests with my VS Code environment, in which upon certain events, a command is executed which invokes my unit tests and reports the results in the IDE.
"python -m pytest --cov=Scripts --cov-config ${workspaceRoot}/.coveragerc --cov-report html:${workspaceRoot}/locale/coverage_html --cov-report xml:${workspaceRoot}/local/coverage.xml --cov-report annotate:${workspaceRoot}/local/coverage_annotate ${workspaceRoot}/UnitTests/ "
Here, ${workspaceRoot} is provided by the automation utility to point to the current 'home' directory of my project.
Unfortunately, pytest-cov does not expose an option to specify an output file location, likely because coverage does not expose a way to do so outside using an environment variable.
The problem with the approach I've defined here is that because it's VS Codes plugin system doing the actual command invocation, my "current working directory" at execution time is the Microsoft VS Code folder in C:\Program Files, meaning there's no write permissions and coverage throws an exception.
My solution would be to use the data_file field in the .coveragerc file to point to my project directory, but that would mean I have to hardcode the path to the project on my local machine, which doesn't work when I move the coverage analysis to our CI system.
If there was a key-word exposed in the config file which exposed the path to the target module, I could use that to set the data_file path properly.
Am I making sense? Is there some mechanism I'm not aware of that could help me here?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the issue's .coveragerc example and the data_file setting, then trace how the shown pytest-cov command resolves output paths when invoked from VS Code. Determine whether a portable configuration mechanism is within scope and define completion around producing coverage output in the project directory under both VS Code and CI.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, vscode
- Domain
- testing-qa, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100