【问题标题】:Can I set pytest command line arguments in conftest?我可以在 conftest 中设置 pytest 命令行参数吗?
【发布时间】:2020-05-02 17:15:12
【问题描述】:

我想做的pytest总是会涉及短回溯(--tb=short)和报告跳过原因(-rsx

所以我不需要每次都做 pytest --tb=short -rsx ,我可以在某个地方指定它,也许是 conftest.py 吗?

谢谢

【问题讨论】:

    标签: python pytest


    【解决方案1】:

    如果您总是想涉及短回溯并报告跳过原因,您可以将其写入配置文件pytest.ini

    [pytest]
    addopts = -rsx --tb=short
    

    或者,您可以设置PYTEST_ADDOPTS 环境变量以在使用环境时添加命令行选项:

    export PYTEST_ADDOPTS="-rsx --tb=short"
    

    【讨论】:

    • 谢谢.. pytest.ini 会很好用的。
    猜你喜欢
    • 1970-01-01
    • 2020-11-27
    • 1970-01-01
    • 2012-10-27
    • 2021-08-12
    • 2018-02-15
    • 2019-11-11
    • 2017-05-25
    • 1970-01-01
    相关资源
    最近更新 更多