Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
nedbat opened this issue Nov 28, 2017 · 7 comments
Closed

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

nedbat opened this issue Nov 28, 2017 · 7 comments
Labels
bug Something isn't working

Comments

@nedbat
Copy link
Owner

nedbat commented Nov 28, 2017

Originally reported by Daniel Hahler (Bitbucket: blueyed, GitHub: blueyed)


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

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

[run]
source = .

[report]
include = mod/*,tests/*

This appeared with coveragepy 4.4.2 and appears to be a side effect of fixing https://bitbucket.org/ned/coveragepy/issues/265.


@nedbat
Copy link
Owner Author

nedbat commented Nov 28, 2017

Original comment by Daniel Hahler (Bitbucket: blueyed, GitHub: blueyed)


Shouldn't run_include / report_include be kept separate really?

diff --git a/coverage/config.py b/coverage/config.py
index [50027274 (bb)](https://bitbucket.org/ned/coveragepy/commits/50027274)..2209e25a [100644 (bb)](https://bitbucket.org/ned/coveragepy/commits/100644)
--- a/coverage/config.py
+++ b/coverage/config.py
@@ -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:
                 break
 
-        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:

@nedbat
Copy link
Owner Author

nedbat commented Nov 28, 2017

Original comment by Daniel Hahler (Bitbucket: blueyed, GitHub: blueyed)


This warnings causes test failures for me when I am capturing output, and pytest-cov triggers the run for subprocess.call being used in the test.
The warning ("'Coverage.py 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).

@nedbat
Copy link
Owner Author

nedbat commented Nov 28, 2017

Original comment by Daniel Hahler (Bitbucket: blueyed, GitHub: blueyed)


The workaround is to use disable_warnings = include-ignored with [run].

@nedbat
Copy link
Owner Author

nedbat commented Nov 28, 2017

Hmm, I see what you mean. I'll look into this.

@nedbat
Copy link
Owner Author

nedbat commented Jan 21, 2018

Fixed in 1031ead7ca4c (bb)

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! :)

@nedbat
Copy link
Owner Author

nedbat commented Jan 21, 2018

Don't confuse run-include with report-include (and also omit). Fixes #621 and #622.

→ <<cset 1031ead7ca4c (bb)>>

@nedbat
Copy link
Owner Author

nedbat commented Feb 3, 2018

This was included in coverage.py v4.5, released today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant