gpt4 book ai didi

运行测试时出现 Python pytest 警告

转载 作者:行者123 更新时间:2023-12-04 16:28:45 29 4
gpt4 key购买 nike

我有一个 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 =====================

版本信息:
- 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

最佳答案

你有两个选择。

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

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

[pytest]
filterwarnings =
ignore::DeprecationWarning

关于运行测试时出现 Python pytest 警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56709696/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com