运行测试时Python pytest警告

Ren*_*ene 2 python warnings pytest

我有一个myfun.py包含我的功能的文件。
我有一个test_myfun.py文件pytest测试。

跑步时 pytest test_myfun.py,测试本身运行没有错误,但 pytest 给出警告。

任何建议如何解决这些警告?

=============================== warnings summary ===============================
/home/rene/anaconda3/lib/python3.7/site-packages/html5lib/_trie/_base.py:3
  /home/rene/anaconda3/lib/python3.7/site-packages/html5lib/_trie/_base.py:3: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
    from collections import Mapping

/home/rene/anaconda3/lib/python3.7/site-packages/scrapy/item.py:8
  /home/rene/anaconda3/lib/python3.7/site-packages/scrapy/item.py:8: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
    from collections import MutableMapping

-- Docs: https://docs.pytest.org/en/latest/warnings.html
==================== 11 passed, 2 warnings in 7.47 seconds =====================
Run Code Online (Sandbox Code Playgroud)

版本信息: -Python
3.7.3
-pytest 4.6.2

# packages in environment at /home/rene/anaconda3:
#
# Name                    Version                   Build  Channel
pytest                    4.6.2                    py37_0  
pytest-arraydiff          0.3              py37h39e3cac_0  
pytest-astropy            0.5.0                    py37_0  
pytest-doctestplus        0.3.0                    py37_0  
pytest-openfiles          0.3.2                    py37_0  
pytest-remotedata         0.3.1                    py37_0  
pytest-runner             4.4                        py_0  
Run Code Online (Sandbox Code Playgroud)

aws*_*ice 6

你有两个选择。

1) 升级您的软件包,即如果最新版本html5libscrapy已修复这些警告。

2)pytest.ini在你的 repo 的根目录中创建一个文件并给它这些内容,这将使pytest忽略DeprecationWarning

[pytest]
filterwarnings =
    ignore::DeprecationWarning
Run Code Online (Sandbox Code Playgroud)