include-ignored warning when using run.source with report.include

Issue #621 resolved
Daniel Hahler created an issue

Using the following .coveragerc should not cause a warning during run, should it?

--include is ignored because --source is set (include-ignored)

source = .

include = mod/*,tests/*

This appeared with coveragepy 4.4.2 and appears to be a side effect of fixing

Comments (9)

  1. Daniel Hahler reporter

    Shouldn't run_include / report_include be kept separate really?

    diff --git a/coverage/ b/coverage/
    index 50027274..2209e25a 100644
    --- a/coverage/
    +++ b/coverage/
    @@ -178,10 +178,6 @@ def __init__(self):
             self.attempted_config_files = []
             self.config_files = []
    -        # Defaults for [run] and [report]
    -        self._include = None
    -        self._omit = None
             # Defaults for [run]
             self.branch = False
             self.concurrency = None
    @@ -325,9 +321,9 @@ def from_file(self, filename, our_file):
             ('data_file', 'run:data_file'),
             ('debug', 'run:debug', 'list'),
             ('disable_warnings', 'run:disable_warnings', 'list'),
    -        ('_include', 'run:include', 'list'),
    +        ('run_include', 'run:include', 'list'),
             ('note', 'run:note'),
    -        ('_omit', 'run:omit', 'list'),
    +        ('run_omit', 'run:omit', 'list'),
             ('parallel', 'run:parallel', 'boolean'),
             ('plugins', 'run:plugins', 'list'),
             ('source', 'run:source', 'list'),
    @@ -337,8 +333,8 @@ def from_file(self, filename, our_file):
             ('exclude_list', 'report:exclude_lines', 'regexlist'),
             ('fail_under', 'report:fail_under', 'int'),
             ('ignore_errors', 'report:ignore_errors', 'boolean'),
    -        ('_include', 'report:include', 'list'),
    -        ('_omit', 'report:omit', 'list'),
    +        ('report_include', 'report:include', 'list'),
    +        ('report_omit', 'report:omit', 'list'),
             ('partial_always_list', 'report:partial_branches_always', 'regexlist'),
             ('partial_list', 'report:partial_branches', 'regexlist'),
             ('precision', 'report:precision', 'int'),
    @@ -469,12 +465,6 @@ def read_coverage_config(config_file, **kwargs):
                 if config_read:
    -        for attr in ('_omit', '_include'):
    -            value = getattr(config, attr)
    -            if value is not None:
    -                for section in ('run', 'report'):
    -                    setattr(config, section + attr, value)
         # 3) from environment variables:
         env_data_file = os.environ.get('COVERAGE_FILE')
         if env_data_file:
  2. Daniel Hahler reporter

    This warnings causes test failures for me when I am capturing output, and pytest-cov triggers the run for being used in the test. The warning ("' warning: --include is ignored because --source is set (include-ignored)'") is being captured by pytest's capfd then, and is not expected to be there for the test(s).

  3. Ned Batchelder repo owner

    Fixed in 1031ead7ca4c

    What I was forgetting was that there's no need to connect the run and report settings together. Report inclusion and omission will default to the run settings by virtue of the data that the run phase collected. Thanks! :)

  4. Log in to comment