【问题标题】:setuptools: testing my extrassetuptools:测试我的附加功能
【发布时间】:2014-01-08 03:36:27
【问题描述】:

我想支持一个界面,新开发人员只需运行python setup.py test 即可运行我的所有测试。我认为这是合理的。

鉴于我在我的包 (optional features with their own dependencies) 中定义了几个“附加”,我如何确保这些测试在 python setup.py test 下正确运行。

这是不是太期待了?

例如,我尝试将 .[extra-feature-1] 添加到我的 tests_require 列表中,但这显然是一厢情愿。

【问题讨论】:

    标签: python testing setuptools python-unittest


    【解决方案1】:

    为了确保在运行测试时安装了附加组件,您在运行 setup.py 时使用 --extras 参数。

    您可以使用setup.cfg 文件为setup.py 添加默认选项。

    例如在setup.cfg 添加:

    [test]
    extras=1
    

    或者如果你使用pytest:

    [aliases]
    test=pytest
    [pytest]
    extras=1
    

    这样,运行python setup.py test 会自动将--extras 添加到命令中

    【讨论】:

    • "'test' 没有这样的选项'extras'"
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-07-12
    • 2013-05-03
    • 1970-01-01
    • 2018-04-16
    • 2012-07-28
    • 1970-01-01
    • 2015-12-31
    相关资源
    最近更新 更多