pytest-dev / pytest-cov

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

DeprecationWarning with pytest 7.2 #561

Closed FranzForstmayr closed 1 year ago

FranzForstmayr commented 1 year ago

Summary

Using pytest 7.2 with current pytest-cov produces a DeprecationWarning

Expected vs actual result.

Test fails with:

pytest.PytestDeprecationWarning: The hookimpl CovPlugin.pytest_configure_node uses old-style configuration options (marks or attributes).

when treating warnings as errors

Versions

Tox output

py37 installed: alabaster==0.7.12,attrs==22.1.0,Babel==2.10.3,backcall==0.2.0,beautifulsoup4==4.11.1,bleach==5.0.1,certifi==2022.9.24,charset-normalizer==2.1.1,coverage==6.5.0,cycler==0.11.0,debugpy==1.6.3,decorator==5.1.1,defusedxml==0.7.1,docutils==0.17.1,entrypoints==0.4,et-xmlfile==1.1.0,exceptiongroup==1.0.0rc9,fastjsonschema==2.16.2,flake8==5.0.4,fonttools==4.38.0,idna==3.4,imagesize==1.4.1,importlib-metadata==4.2.0,importlib-resources==5.10.0,iniconfig==1.1.1,ipykernel==6.16.2,ipython==7.34.0,ipywidgets==8.0.2,jedi==0.18.1,Jinja2==3.1.2,jsonschema==4.16.0,jupyter_client==7.4.4,jupyter_core==4.11.2,jupyterlab-pygments==0.2.2,jupyterlab-widgets==3.0.3,kiwisolver==1.4.4,MarkupSafe==2.1.1,matplotlib==3.5.3,matplotlib-inline==0.1.6,mccabe==0.7.0,mistune==2.0.4,nbclient==0.7.0,nbconvert==7.2.2,nbformat==5.7.0,nbsphinx==0.8.9,nbval==0.9.6,nest-asyncio==1.5.6,networkx==2.6.3,numpy==1.21.6,openpyxl==3.0.10,packaging==21.3,pandas==1.3.5,pandocfilters==1.5.0,parso==0.8.3,pexpect==4.8.0,pickleshare==0.7.5,Pillow==9.2.0,pkgutil_resolve_name==1.3.10,pluggy==1.0.0,prompt-toolkit==3.0.31,psutil==5.9.3,ptyprocess==0.7.0,pycodestyle==2.9.1,pyflakes==2.5.0,Pygments==2.13.0,pyparsing==3.0.9,pyrsistent==0.18.1,pytest==7.2.0,pytest-cov==3.0.0,python-dateutil==2.8.2,python-ivi==0.14.9,pytz==2022.5,PyVISA==1.12.0,pyzmq==24.0.1,requests==2.28.1,-e git+ssh://git@github.com/FranzForstmayr/scikit-rf.git@f28c323ce8441b490e173ecca20772616aa90b39#egg=scikit_rf,scipy==1.7.3,six==1.16.0,snowballstemmer==2.2.0,soupsieve==2.3.2.post1,Sphinx==4.3.2,sphinx-rtd-theme==1.0.0,sphinxcontrib-applehelp==1.0.2,sphinxcontrib-devhelp==1.0.2,sphinxcontrib-htmlhelp==2.0.0,sphinxcontrib-jsmath==1.0.1,sphinxcontrib-qthelp==1.0.3,sphinxcontrib-serializinghtml==1.1.5,tinycss2==1.2.1,tomli==2.0.1,tornado==6.2,traitlets==5.5.0,typing_extensions==4.4.0,urllib3==1.26.12,wcwidth==0.2.5,webencodings==0.5.1,widgetsnbextension==4.0.3,zipp==3.10.0

Config

[tool.pytest.ini_options]
testpaths = [
    "skrf",
    "doc/source/examples",
    "doc/source/tutorials"
]
addopts = "--cov=skrf --ignore-glob='*.ipynb_checkpoints'"
norecursedirs = [
    "skrf/vi",
    "skrf/src",
    "doc/source/examples/instrumentcontrol"
]
filterwarnings = [
    "error",
    "ignore::pytest.PytestRemovedIn8Warning"
]

This line fixes the error, when added to filterwarnings

"ignore:.*hookimpl.*old-style configuration options.*:pytest.PytestDeprecationWarning"

Code

Not required

altendky commented 1 year ago

I was starting to provide more context here and a full traceback and... Then I realized I'm getting pytest-cov==2.12.1 installed for some reason. I guess another dep is holding it back. I'll follow up when I figure out what.

Are you getting an old version as well?

FranzForstmayr commented 1 year ago

No, pytest-cov==3.0.0 is installed (as requested by dependency specification).

altendky commented 1 year ago

The new hook setup was implemented in v4 https://github.com/pytest-dev/pytest-cov/commit/b077753f5d9d200815fe500d0ef23e306784e65b and released on September 28 https://pypi.org/project/pytest-cov/4.0.0/.

altendky commented 1 year ago

https://github.com/scikit-rf/scikit-rf/pull/784 updates to 4.0 and removes the deprecation warning ignore. We'll see how it works out after the workflow runs are approved.

My issue seems to be around pip and trouble with picking the coverage pre-release conflicting with the pytest-cov dependency on coverage[toml] where the extra is the trigger for trouble I believe. Reported as https://github.com/pypa/pip/issues/11565.

altendky commented 1 year ago

With that merged, are you comfortable closing this @FranzForstmayr?

FranzForstmayr commented 1 year ago

Yes of course! Thanks for the fast fix! :)