如何禁用 PytestDeprecationWarning:不推荐直接构建 Flake8Item,请使用 Flake8Item.from_parent

Yed*_*rab 1 python pytest flake8

  • 当我python setup.py test在我的项目文件夹中运行命令以使用setup.cfg配置测试我的包时,我收到了此警告消息。
  • 我怎样才能禁用它?

? python setup.py test就像pytest --flake8命令一样。

============================================================================================== warnings summary =============================================================================================== 
c:\users\yedhrab\appdata\local\programs\python\python38\lib\site-packages\pytest_flake8.py:65
  c:\users\yedhrab\appdata\local\programs\python\python38\lib\site-packages\pytest_flake8.py:65: PytestDeprecationWarning: direct construction of Flake8Item has been deprecated, please use Flake8Item.from_parent
    return Flake8Item(

-- Docs: https://docs.pytest.org/en/latest/warnings.html
=========================================================================================== short test summary info =========================================================================================== 
SKIPPED [1] c:\users\***\appdata\local\programs\python\python38\lib\site-packages\pytest_flake8.py:106: file(s) previously passed FLAKE8 checks
=================================================================================== 9 passed, 1 skipped, 1 warning in 0.33s =================================================================================== 
Run Code Online (Sandbox Code Playgroud)

Suz*_*ana 5

如果您不想禁用所有警告而只想禁用特定的 pytest 警告,请使用以下-W参数:

pytest -W ignore::pytest.PytestDeprecationWarning
Run Code Online (Sandbox Code Playgroud)