问题描述
我有一个使用 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]