pytest-cov icon indicating copy to clipboard operation
pytest-cov copied to clipboard

warning: --include is ignored because --source is set (include-ignored) when using -n option w/ coveragerc

Open zzzeek opened this issue 6 years ago • 1 comments

Over on the coverage side, this issue: https://bitbucket.org/ned/coveragepy/issues/621/include-ignored-warning-when-using seems to deal with this, but I am getting it with pytest-cov only when using xdist mode:

Coverage.py warning: --include is ignored because --source is set (include-ignored)

This is against SQLAlchemy / Alembic test suites, which are complicated, so for a simpler test case I can apply it to the Mako test suite that doesn't do any pytest tricks.

First use a .coveragerc like this:

[run]
include=mako/*

[report]
omit=mako/testing/*

then when I run a few Mako tests using -n4, I get the warning several times, output below. If I don't use "-n" , or if I remove the .coveragerc, the warning goes away.

$ py.test test/test_def.py  --cov=mako -n4
================================================================= test session starts ==================================================================
platform linux -- Python 3.7.4, pytest-5.2.2, py-1.8.0, pluggy-0.13.0 -- /home/classic/.venv3/bin/python3
cachedir: .pytest_cache
rootdir: /home/classic/dev/mako, inifile: setup.cfg
plugins: forked-1.1.3, xdist-1.30.0, cov-2.8.1
[gw0] linux Python 3.7.4 cwd: /home/classic/dev/mako
[gw1] linux Python 3.7.4 cwd: /home/classic/dev/mako
[gw2] linux Python 3.7.4 cwd: /home/classic/dev/mako
[gw3] linux Python 3.7.4 cwd: /home/classic/dev/mako
[gw0] Python 3.7.4 (default, Jul  9 2019, 16:32:37)  -- [GCC 9.1.1 20190503 (Red Hat 9.1.1-1)]
gw0 ok / gw1 C / gw2 C / gw3 CCoverage.py warning: --include is ignored because --source is set (include-ignored)
[gw1] Python 3.7.4 (default, Jul  9 2019, 16:32:37)  -- [GCC 9.1.1 20190503 (Red Hat 9.1.1-1)]
gw0 ok / gw1 ok / gw2 C / gw3 CCoverage.py warning: --include is ignored because --source is set (include-ignored)
[gw2] Python 3.7.4 (default, Jul  9 2019, 16:32:37)  -- [GCC 9.1.1 20190503 (Red Hat 9.1.1-1)]
gw0 ok / gw1 ok / gw2 ok / gw3 CCoverage.py warning: --include is ignored because --source is set (include-ignored)
[gw3] Python 3.7.4 (default, Jul  9 2019, 16:32:37)  -- [GCC 9.1.1 20190503 (Red Hat 9.1.1-1)]
gw0 ok / gw1 ok / gw2 ok / gw3 okCoverage.py warning: --include is ignored because --source is set (include-ignored)
gw0 [31] / gw1 [31] / gw2 [31] / gw3 [31]
scheduling tests via LoadScheduling

test/test_def.py::DefTest::test_def_args 
test/test_def.py::DefTest::test_def_noargs 
test/test_def.py::DefTest::test_def_operations 
test/test_def.py::DefTest::test_def_blankargs 
[gw2] [  3%] PASSED test/test_def.py::DefTest::test_def_noargs 
[gw0] [  6%] PASSED test/test_def.py::DefTest::test_def_args 
test/test_def.py::DefTest::test_toplevel 
test/test_def.py::DefTest::test_def_py3k_args 
[gw2] [  9%] PASSED test/test_def.py::DefTest::test_toplevel 
[gw1] [ 12%] PASSED test/test_def.py::DefTest::test_def_blankargs 
[gw3] [ 16%] PASSED test/test_def.py::DefTest::test_def_operations 
[gw0] [ 19%] PASSED test/test_def.py::DefTest::test_def_py3k_args 
test/test_def.py::ScopeTest::test_inline_expression_from_arg_one 
test/test_def.py::DefTest::test_inter_def 
test/test_def.py::ScopeTest::test_canget_kwargs 
test/test_def.py::ScopeTest::test_interpret_expression_from_arg_two 
[gw2] [ 22%] PASSED test/test_def.py::ScopeTest::test_inline_expression_from_arg_one 
[gw1] [ 25%] PASSED test/test_def.py::DefTest::test_inter_def 
test/test_def.py::ScopeTest::test_scope_eight 
test/test_def.py::ScopeTest::test_scope_eleven 
[gw0] [ 29%] PASSED test/test_def.py::ScopeTest::test_interpret_expression_from_arg_two 
test/test_def.py::ScopeTest::test_scope_four 
[gw3] [ 32%] PASSED test/test_def.py::ScopeTest::test_canget_kwargs 
test/test_def.py::ScopeTest::test_scope_five 
[gw1] [ 35%] PASSED test/test_def.py::ScopeTest::test_scope_eleven 
test/test_def.py::ScopeTest::test_scope_one 
[gw2] [ 38%] PASSED test/test_def.py::ScopeTest::test_scope_eight 
[gw0] [ 41%] PASSED test/test_def.py::ScopeTest::test_scope_four 
test/test_def.py::ScopeTest::test_scope_nine 
test/test_def.py::ScopeTest::test_scope_seven 
[gw1] [ 45%] PASSED test/test_def.py::ScopeTest::test_scope_one 
[gw3] [ 48%] PASSED test/test_def.py::ScopeTest::test_scope_five 
test/test_def.py::ScopeTest::test_scope_ten 
[gw2] [ 51%] PASSED test/test_def.py::ScopeTest::test_scope_nine 
test/test_def.py::ScopeTest::test_scope_six 
[gw0] [ 54%] PASSED test/test_def.py::ScopeTest::test_scope_seven 
test/test_def.py::ScopeTest::test_scope_two 
test/test_def.py::ScopeTest::test_unbound_scope 
[gw2] [ 58%] PASSED test/test_def.py::ScopeTest::test_scope_two 
[gw3] [ 61%] PASSED test/test_def.py::ScopeTest::test_scope_six 
[gw1] [ 64%] PASSED test/test_def.py::ScopeTest::test_scope_ten 
[gw0] [ 67%] PASSED test/test_def.py::ScopeTest::test_unbound_scope 
test/test_def.py::NestedDefTest::test_nested_2 
test/test_def.py::ScopeTest::test_unbound_scope_two 
test/test_def.py::NestedDefTest::test_nested_def 
test/test_def.py::NestedDefTest::test_nested_def_2 
[gw2] [ 70%] PASSED test/test_def.py::NestedDefTest::test_nested_def 
[gw3] [ 74%] PASSED test/test_def.py::NestedDefTest::test_nested_2 
[gw1] [ 77%] PASSED test/test_def.py::ScopeTest::test_unbound_scope_two 
test/test_def.py::NestedDefTest::test_nested_nested_def 
[gw0] [ 80%] PASSED test/test_def.py::NestedDefTest::test_nested_def_2 
test/test_def.py::NestedDefTest::test_nested_with_args 
test/test_def.py::NestedDefTest::test_nested_nested_def_2 
test/test_def.py::NestedDefTest::test_outer_scope 
[gw3] [ 83%] PASSED test/test_def.py::NestedDefTest::test_nested_with_args 
test/test_def.py::ExceptionTest::test_raise 
[gw1] [ 87%] PASSED test/test_def.py::NestedDefTest::test_nested_nested_def_2 
[gw2] [ 90%] PASSED test/test_def.py::NestedDefTest::test_nested_nested_def 
[gw3] [ 93%] PASSED test/test_def.py::ExceptionTest::test_raise 
test/test_def.py::ExceptionTest::test_handler 
[gw0] [ 96%] PASSED test/test_def.py::NestedDefTest::test_outer_scope 
[gw2] [100%] PASSED test/test_def.py::ExceptionTest::test_handler Coverage.py warning: No data was collected. (no-data-collected)


----------- coverage: platform linux, python 3.7.4-final-0 -----------
Name                        Stmts   Miss  Cover
-----------------------------------------------
mako/__init__.py                1      0   100%
mako/_ast_util.py             505    358    29%
mako/ast.py                    89     23    74%
mako/cache.py                  64     18    72%
mako/cmd.py                    45     45     0%
mako/codegen.py               580    206    64%
mako/compat.py                 92     39    58%
mako/exceptions.py            153    114    25%
mako/ext/__init__.py            0      0   100%
mako/ext/autohandler.py        31     31     0%
mako/ext/babelplugin.py        19     19     0%
mako/ext/beaker_cache.py       48     48     0%
mako/ext/extract.py            71     71     0%
mako/ext/linguaplugin.py       29     29     0%
mako/ext/preprocessors.py       4      4     0%
mako/ext/pygmentplugin.py      55     11    80%
mako/ext/turbogears.py         32     32     0%
mako/filters.py                91     47    48%
mako/lexer.py                 264     74    72%
mako/lookup.py                115     63    45%
mako/parsetree.py             264     68    74%
mako/pygen.py                 138     13    91%
mako/pyparser.py              135     56    59%
mako/runtime.py               427    186    56%
mako/template.py              256    113    56%
mako/util.py                  225    145    36%
-----------------------------------------------
TOTAL                        3733   1813    51%


================================================================== 31 passed in 1.47s ==================================================================
Coverage.py warning: --include is ignored because --source is set (include-ignored)

zzzeek avatar Nov 30 '19 16:11 zzzeek

Fixed as per https://github.com/nedbat/coveragepy/issues/621#issuecomment-399708736 by using disable_warnings=include-ignored in the [run] section.

casperdcl avatar Feb 27 '22 22:02 casperdcl