python - 调用 setup.py test 命令时如何告诉 pbr 使用 pytest?

标签 python pytest python-pbr

在使用pbr简化Python打包的同时,我们需要配置什么才能让它在python setup.py test时使用pytest命令被执行。

运行 pytest 没有任何问题。

最佳答案

在 setup.py 中:

setup(
    setup_requires=['pbr>=1.9', 'setuptools>=17.1', 'pytest-runner'],
    pbr=True,
)

在 setup.cfg 中(在标准 pbr 配置之后):

[aliases]
test=pytest

在 test-requirements.txt(与 requirements.txt 相同的目录)中:

pytest

如果您的测试在应用程序代码之外,您还需要使用 setup.cfg 中的 addopts 指定您的测试目录。例如,如果您的目录结构类似于 this page 上的第一个示例, 你应该有

[tool:pytest]
addopts = tests

关于python - 调用 setup.py test 命令时如何告诉 pbr 使用 pytest?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40592797/

相关文章:

python - 如何对大型数据集进行多线程大量 pandas 数据帧选择调用

python - 如何在每个 py.test 断言失败时调用方法?

python - 使用 py.test 数据驱动测试进行设置和拆卸

python - 安装 python 模块 (pbr) 时出现问题

python - 如何从源代码使用 pbr 版本?

python - 按位置删除文本 tkinter

python子进程输出到列表或文件

python - 从 Python 在 LibreOffice 中创建复选框

python - 在pytest测试开始时创建服务器

python - 安装pbr时出错