FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

`.coveragerc` vs. `tox.ini` · Issue #144 · codecov/codecov-python · GitHub

This repository was archived by the owner on May 21, 2025. It is now read-only.

Repository navigation

This repository was archived by the owner on May 21, 2025. It is now read-only.

.coveragerc vs. tox.ini #144

Description

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?

Activity

  1. Ademord commented on Jun 13, 2018

    Did you manage to get this solved? :(

  2. Peque commented on Jun 13, 2018

    Author

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

  3. Ademord commented on Jun 13, 2018

    I fixed my issue. My use case worked when I used:

    [coverage:report]
       pragma: no cover
       pragma: $envvar cover
    
    

    where envvar=NO would be set if i wasnt using it 😄
    You can look at more details about my case here.

  4. Peque commented on Jun 13, 2018

    Author

    @Ademord Yeah, it seems it does not apply to my use case, but thanks for sharing! 😊

  5. self-assigned this
    on Nov 29, 2020
  6. removed their assignment
    on Jul 21, 2021
  7. mpurnell1 commented on Oct 30, 2022

    I'm not sure if this applies to your use case (and also I'm 4 years late), but codecov supports a section in their yaml file (codecov.yml in root directory) called ignore whcih accepts regex expressions to exclude. Mine looks similar to below to ignore django files

    coverage:
      status:
        project:
          default:
            threshold: 0.15%
    
    ignore:
      - "myProject*"
      - "**/admin"
      - "**/migrations"
      - "**/pycache"
      - "**/templatetags"
      - "**/tests"
      - "**/views"
      - "manage.py"
      - "**/__init__.py"
      - "**/decorators.py"
      - "**/fields.py"
      - "**/forms.py"
      - "**/middleware.py"
      - "**/mixins.py"
      - "**/sitemaps.py"
      - "**/tasks.py"
      - "**/urls.py"
      - "**/utils"
      - "**/errors.py"
    
  8. ssbarnea commented on 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL