pantsbuild / pants

The Pants Build System
https://www.pantsbuild.org
Apache License 2.0
3.32k stars 636 forks source link

coverage broken with pytest 7.2.0 #17740

Open mpcusack-color opened 1 year ago

mpcusack-color commented 1 year ago

Describe the bug We recently upgraded to pytest==7.2.0 and noticed we can no longer use test --use-coverage.

pytest.PytestDeprecationWarning: The hookimpl CovPlugin.pytest_configure_node uses old-style configuration options (marks or attributes).
Please use the pytest.hookimpl(optionalhook=True) decorator instead
 to configure the hooks.
 See https://docs.pytest.org/en/latest/deprecations.html#configuring-hook-specs-impls-using-markers
 at /home/mpcusack/.cache/pants/named_caches/pex_root/venvs/s/4ea0b489/venv/lib/python3.8/site-packages/pytest_cov/plugin.py:256

https://docs.pytest.org/en/7.2.x/changelog.html#pytest-7-2-0-2022-10-23 deprecated a hook style in https://github.com/pytest-dev/pytest/issues/4562. This wasn't adopted in pytest-cov until 4.0.0 https://pytest-cov.readthedocs.io/en/latest/changelog.html#id1

Pants hardcodes the pytest-cov version less than 3.1: https://github.com/pantsbuild/pants/blob/bca1b5a4ae311511fe87ff0dd3ccecc32955d024/src/python/pants/backend/python/subsystems/pytest.py#L79

Pants version 2.15.0a1

OS Linux

mpcusack-color commented 1 year ago

Oh I was using extra_requirements.add. I guess I can override with extra_requirements.

Eric-Arellano commented 1 year ago

Did that fix it? Still, we probablly should update the default versions of these tools to be newer

mpcusack-color commented 1 year ago

The override fixes it. +1 to updating the default version.

Eric-Arellano commented 1 year ago

+1 to updating the default version.

PR would be welcomed if you get a chance. You'd bump this:

https://github.com/pantsbuild/pants/blob/300c4426c4cc86220b8a9b4d58424e8e65ed9c4d/src/python/pants/backend/python/subsystems/pytest.py#L79

And then run build-support/bin/generate_all_lockfiles.sh --tool pytest.