Skip to content

Allow [paths] normalization to run against a single report #1212

Closed
@eric-wieser

Description

@eric-wieser

When running coverage against an installed package, I have a config file like:

[paths]
source =
    src
    */site-packages

[run]
branch = true
source =
    tests
    my_package_name

and a working directory like:

src/my_package_name/
   foo.py
tests/
   test_foo.py
setup.py
.coveragerc

When I run coverage run -m pytest, I get coverage information from coverage report for filenames like

C:\Users\me\AppData\Local\Programs\Python\Python38\Lib\site-packages\my_package_name\foo.py
tests\test_foo.py

However, if I run

mv .coverage .coverage.hack  # I can't combine it without renaming
coverage combine
coverage report

Then I the output has the filenames I (and tools like codecov which match filenames against files in a git repo) want:

src\my_package_name\foo.py
tests\test_foo.py

Describe the solution you'd like
Either the PathAlias logic should be applied by default when producing a report, or there should be a command-line-flag / configuration option to make it behave this way

Additional context
Somewhat related to pytest-dev/pytest-cov#98

Activity

added this to the Next milestone on Nov 6, 2021
removed this from the Next milestone on Nov 13, 2021
nedbat

nedbat commented on Nov 26, 2022

@nedbat
Owner

Issue #713 turned out to be another example of this.

I'm trying to think of a situation where it would be bad to re-map the paths during reporting... I'd love to avoid having a command-line option for this.

nedbat

nedbat commented on Nov 27, 2022

@nedbat
Owner

This is now implemented in commit 0818611.

added and removed on Nov 27, 2022
nedbat

nedbat commented on Dec 3, 2022

@nedbat
Owner

This is now released as part of coverage 7.0.0b1.

added a commit that references this issue on May 5, 2023
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

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @nedbat@eric-wieser

        Issue actions

          Allow [paths] normalization to run against a single report · Issue #1212 · nedbat/coveragepy