gpt4 book ai didi

Python 添加 pytest --black 到测试套件

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

我使用 pytest 来测试我的 Python 项目。我想要做的是在我的测试套件中添加一个函数来检查我的代码是否为“黑色”格式。当我按下命令 "pytest --black"我的整个项目都按照我的意愿进行了测试。如何在我的测试套件中添加此函数并在运行 "python setup.py pytest" 时检查相同的内容命令?

最佳答案

pytest.ini has an addopts key它确实做到了它在 jar 头上所说的:它为 pytest 添加了选项您使用的命令行。
所以在你的程序的根目录下,你应该能够创建一个 pytest.ini文件包含:

[pytest]
addopts = --black
它应该在你的 pytest 运行中自动启用 black-as-test。

关于Python 添加 pytest --black 到测试套件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63413227/

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