`.coveragerc` vs. `tox.ini`
See original GitHub issueInitial setup
I have a .coveragerc
file like:
[report]
exclude_lines =
def __repr__
I run my tests with tox
which in turn runs pytest
with pytest-cov
, which means my tox.ini
file looks like this:
[testenv]
deps =
pytest
pytest-cov
commands = pytest --cov
Then:
- When running
tox
in my machine the showed report correctly excludes those lines. - When the CI service runs
tox
, it also shows the correct report, with those lines excluded. - Just after running
tox
, the CI service runscodecov
and the report uploaded to Codecov is also correct.
Broken setup
Now I remove .coveragerc
file and move those lines to tox.ini
:
[coverage:report]
exclude_lines =
def __repr__
Then:
- When running
tox
in my machine the showed report correctly excludes those lines. - When the CI service runs
tox
, it also shows the correct report, with those lines excluded. - Just after running
tox
, the CI service runscodecov
and the report uploaded to Codecov, this time, differs. It does not have those excluded lines, so they are reported as not covered.
Questions
- Why is this happening?
- Is there any way I could fix that?
- Is there an option in
codecov
to specify the coverage configuration is intox.ini
- Should not
codecov
read that file by default?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:6
Top Results From Across the Web
Platform Dependent Python Coverage Test with Tox
These lines read from .coveragerc.in , substitute {platform} with the appropriate platform name, and write it to a temporary file that coverage.
Read more >Configuration — pytest-cov 4.0.0 documentation
.coveragerc is a magic name: it's the default file but it also means “try to also lookup coverage configuration in ; tox.ini or...
Read more >tox.ini: Updated [testenv:cover] so that coverage generates a ...
tox.ini: Updated [testenv:cover] so that coverage generates a report. Browse Source. Also added omissions in .coveragerc to ensure that the report doesn't ...
Read more >Making py.test, coverage and tox work together: __init__.py in ...
test - Good Integration Practices (the very bottom of the page). Simplified project structure: setup.py tox.ini .coveragerc project/ __init__.py ...
Read more >General tips and tricks — tox 3.1.1 documentation
in the testenv or testenv:NAME section of your tox.ini commands = pytest {posargs} ... In a testenv environment you can specify any command...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@Ademord Sadly no. I am still using a separate
.coveragerc
file and, as you can see, got no response from @codecov. 😕I think that the situation it getting worse since almost everyone is moving to pyproject.toml including coveragepy.
I observed that codecov does not load the excludes from the valid codeveragepy config. ansible/ansible-lint@main/pyproject.toml#L13-L24
In my particular case I was interested about
exclude_lines