pytest-cov
                                
                                 pytest-cov copied to clipboard
                                
                                    pytest-cov copied to clipboard
                            
                            
                            
                        `pytest-cov` sets `--source` option automatically even if there is only an `include` section in `.coveragerc`
Summary
Original issue has been opened at coveragepy: https://github.com/nedbat/coveragepy/issues/1355. I get CoverageWarning: --include is ignored because --source is set (include-ignored) self.warn("--include is ignored because --source is set", slug="include-ignored") although only include is specified in .coveragerc and nowhere --source is specified.
As @nedbat correctly commented, it seems that pytest-cov seems to automatically set the --source option. Removal of pytest-cov resolved the problem.
Expected vs actual result
Expected: No CoverageWarning: --include is ignored because --source is set (include-ignored) self.warn("--include is ignored because --source is set", slug="include-ignored") and not setting --source when source is nowhere specified.
Reproducer
Minimal example is here: https://github.com/gro1m/coverageminimalexample
NOTE: I substituted my HOME PATH with ~ on line 6 in the generated coverage.xml, this is an alteration I did after the program has been run.
Commands run: pytest
Versions
Python: 3.9.7, 3.10.4 respectively coveragepy: 6.3.2 pytest: 7.1.1 pytest-cov: 3.0.0
Config
.coveragerc
[run]
include =
  pycobertura/*
pytest.ini: https://github.com/aconrad/pycobertura/blob/master/pytest.ini
tox.ini: https://github.com/aconrad/pycobertura/blob/e8150644ee644ec95519d1dc8c99878e67a38e68/tox.ini
setup.cfg: https://github.com/aconrad/pycobertura/blob/master/setup.cfg
Code
- Minimal example: https://github.com/gro1m/coverageminimalexample
- Actual use case: https://github.com/aconrad/pycobertura/tree/e8150644ee644ec95519d1dc8c99878e67a38e68 (the current master branch contains a workaround based on the following PR that does not use pytest-cov anymore: https://github.com/aconrad/pycobertura/pull/140)