-
Notifications
You must be signed in to change notification settings - Fork 212
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
Add --cov-omit option #373
Comments
Coverage will read settings from setup.cfg, or tox.ini, or pyproject.toml files. There's no need to add another option to an already cluttered command line. |
Yes but it can be annoying to create a configuration file only to add a simple option to the command. |
@roipoussiere You don't have any of these files? setup.cfg, tox.ini, pyproject.toml? |
No, any of them. I would like to keep my root tree as clean as possible. |
I understand that impulse. We would like to keep our plugin as simple as possible. |
I think this suggestion is completely valid. Sometimes I just want to try a command to see if something works, without creating a config file. That's the whole point of command line arguments. If I need to use the same configuration repeatedly, I'll know myself to create a config file. I don't need you to dictate that I should always create a config file. And it's not like this suggestion is asking for a very complex argument. Whatever you already support in the config file, just put it in the command line. With your logic (to keep it simple) you may as well argue that your plugin shouldn't support any command line argument at all. |
@nedbat How would you feel about having a general "coverage option" commandline argument, similar to pytest's |
@The-Compiler I think your suggestion somewhat misses the point:
|
It does?
Which is why I proposed an option which lets you set coverage config options without having a config file.
How so? From what I can tell, pytest-cov does not handle |
@The-Compiler ok nevermind, my bad. I thought |
The discussion continues here with good arguments but the issue is still closed. Is it possible to re-open it? |
It is certainly possible but whomever reopens it should pledge to maintain an increasing cornucopia of options and switches. That person isn't me and I don't see anyone offering their time when clearly there are alternatives to another cli option. |
In that case I think the issue should be reopened so that anyone interested
can pick it up. Closed issue means that the maintainer of this project
isn't interested.
In other words, if the maintainer of this project is open to this feature
being implemented, the issue should be open.
…On Sun, May 10, 2020, 11:08 Ionel Cristian Mărieș ***@***.***> wrote:
It is certainly possible but whomever reopens it should pledge to maintain
an increasing cornucopia of options and switches. That person isn't me and
I don't see anyone offering their time when clearly there are alternatives
to another cli option.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#373 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAUCG73DNG3YFTFZMA65LFLRQ3USPANCNFSM4J3H5WLQ>
.
|
I'm not interested. I was only alluding that maintenance is scarce. |
@ionelmc How do you feel about my proposal in #373 (comment)? That could possibly even replace any existing commandline options which just get passed through to coverage.py currently. However, it means coverage.py would need some kind of API to pass additional options (while still reading its config file). |
I guess it could be acceptable if that makes it possible to remove other cli arguments. |
This would be a really nice QOL feature |
Yeah, I've been waiting for this for several years now and still nothing. Instead in every one of my projects I have to hack the shared config file that all my projects use with multiple sed commands. Sad. |
@cygnus2048 I don't understand how you are using sed on a shared config file? How does that help you omit files? |
I believe the dev spoke past the original ask here. If you came to this thread looking for a solution to be able to specify both source files to include in coverage, and also paths to omit from coverage, you should use the [tool.coverage] metadata in your pyproject.toml. You do not need to create a .coveragerc file, and doing such would obviously not be canonical in modern python. Here is an example for adding omit options to your pyproject.toml: [tool.pytest.ini_options]
testpaths = ["tests"]
norecursedirs = ["dist", "build", "dev", "typings"]
addopts = ["--cov=./"]
[tool.coverage.run]
source = ["./*"]
omit = ["dev/*", "tests/*"] This satisfies canonical python projects, since all of them should be using a single pyproject.toml to define their project's metadata. |
I have a common coverage config file that is copied into each project during the build. As one of the final steps of the build I run multiple sed commands to add to the "omit" section of that config file. It works, but less than desirable. Having a command line arg would make this much simpler and cleaner. Thanks. |
for projects that have multiple test-suites (say units vs smoke-testing) using a base coverage config file + a few extra options would be very nice to have. more specifically, i want to do things like run unit-tests and omit coverage for afaik, currently the best solution here is to have multiple .coveragerc's where the vast majority of the content is redundant and then has to be kept in sync. i imagine this scenario is fairly common; just wanted to share that everyone who is interested in this is not trying to completely avoid config files and put everything on a CLI invocation. i have and enjoy config files!, but i don't want half a dozen for simple tasks, so base configs + CLI overrides seems like the way to go. |
Similar to
--omit
option in coverage.py, this option could be used to ignore some specific files.Ignoring files can be done with a
.coveragerc
file, but many developers don't want to add an other file in their project root folder just to ignore one or two folder during the coverage analysis.related to #193
The text was updated successfully, but these errors were encountered: