pytest-dev / pytest-cov

Coverage plugin for pytest.
MIT License
1.72k stars 211 forks source link

cov-config file argument ignored when tox.ini exists #615

Open schivmeister opened 10 months ago

schivmeister commented 10 months ago

Summary

When supplying --cov-config=$file (where $file is e.g. setup.cfg) in the presence of a tox.ini with a [pytest] section, pytest/coverage will continue to pick up configuration from tox.ini.

Expected vs actual result

Expected: Configuration from $file is picked up because an override argument has been supplied. Actual: The --cov-config argument is being ignored when there is a valid tox.ini with a [pytest] section.

Reproducer

Versions

Windows 11 Pro 22H2 Python 3.8.18 (Anaconda)

pip list

pytest                        7.4.2
pytest-cov                    4.1.0

Config

tox.ini (w/ empty pytest section)

[tox]
skipsdist = true
envlist = py38

[testenv]
passenv = *
deps =
    -rrequirements.txt
commands =
    python -m pytest

[pytest]

setup.cfg (w/ additional pytest-cov config/opts)

[tool:pytest]
addopts =
    --cov-report=xml
    -r a
    -q
    -v
    --gherkin-terminal-reporter
    --log-level=DEBUG

Code

Above config files are the MWE. The test output will not contain the XML file from the configuration in $file (e.g. setup.cfg) because the tox.ini file is prioritized, which has an empty [pytest] section.

javiersrf commented 9 months ago

I got the same problem but using --cov-config=setup.cfg. Still using the values of .coveragerc :disappointed: