Skip to content

Feature request: Report when excluded lines are executed #619

Closed

Description

@nedbat

Originally reported by Toshio Kuratomi (Bitbucket: toshio, GitHub: toshio)


I've found that I use coverage's exclude_lines configuration[1]_ to exclude code that I determine is unreachable in the environment under test. For me, this doesn't mean code like repr() which could be called during a test run but things shielded by "if False:" or by "if six.PY3" under Python2[2]_.

_[1]: http://coverage.readthedocs.io/en/coverage-4.2/excluding.html

_[2]: https://anonbadger.wordpress.com/2017/11/24/better-unittest-coverage-stats-excluding-code-that-only-executes-on-python-2-3/

I talked to a detractor of this usage of excluding lines from the reports and realized that for my use case it would be helpful if I could have a configuration switch which would make coverage report when code that I've marked for exclusion was executed. If it's executed, then it's obviously not unreachable which means that either my code isn't doing what I thought it was or my listing the code for exclusion from the coverage report should be revisited. (It needs to be a toggle since some people will have different use cases than I do. For instance, the use case in coverage's docs about marking debugging-only code for exclusion would want to toggle this new feature off).


Activity

  1. nedbat commented on Nov 25, 2017

    @nedbat
    MemberAuthor

    Duplicate of #251.

  2. nedbat commented on Nov 25, 2017

    @nedbat
    MemberAuthor

    Original comment by Toshio Kuratomi (Bitbucket: toshio, GitHub: toshio)


    Agreed, #251 describes the same request; jsut with a different justification in the initial comment.

  3. added
    enhancement
    on Jun 23, 2018
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

    enhancementreport

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions