【问题标题】:How do I tell pbr to use pytest when setup.py test command is invoked?调用 setup.py test 命令时,如何告诉 pbr 使用 pytest?
【发布时间】:2016-11-14 15:55:08
【问题描述】:

在使用pbr 来简化Python 打包时,我们需要配置什么才能使其在执行python setup.py test 命令时使用pytest

运行pytest 没有任何问题。

【问题讨论】:

    标签: python pytest python-pbr


    【解决方案1】:

    在 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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-02
      • 1970-01-01
      • 1970-01-01
      • 2013-07-09
      • 1970-01-01
      相关资源
      最近更新 更多