question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`.coveragerc` vs. `tox.ini`

See original GitHub issue

Initial 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 runs codecov 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 runs codecov 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 in tox.ini
  • Should not codecov read that file by default?

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:2
  • Comments:6

github_iconTop GitHub Comments

1reaction
Pequecommented, Jun 13, 2018

@Ademord Sadly no. I am still using a separate .coveragerc file and, as you can see, got no response from @codecov. 😕

0reactions
ssbarneacommented, Nov 26, 2022

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found