Skip to content

pytest-cov sets --source option automatically even if there is only an include section in .coveragerc #532

@gro1m

Description

@gro1m

Summary

Original issue has been opened at coveragepy: nedbat/coveragepy#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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions