为什么 pytest 不使用 pyproject.toml 来表示这个弃用警告

问题描述

我有一个使用 pytest 和诗歌管理的 django 项目。

我想将我的 pytest 配置放入 pyproject.toml 文件中,所以我添加了:

[tool.pytest]
filterwarnings = ["ignore::django.utils.deprecation.RemovedInDjango40Warning","ignore::django.utils.deprecation.RemovedInDjango41Warning"]

然而,这并没有什么区别 - 警告没有被过滤。

如果我添加一个包含以下内容的 pytest.ini 文件...

[pytest]
filterwarnings =
    ignore::django.utils.deprecation.RemovedInDjango40Warning
    ignore::django.utils.deprecation.RemovedInDjango41Warning

...它工作得很好。

我的 pyproject.toml 或我的 pytest 配置有什么问题,没有被接收到?

解决方法

根据 pytest's docs 部分名称应为 [tool.pytest.ini_options]

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...