【问题标题】:Tox: different test sets during local and gitlab CI runsTox:本地和 gitlab CI 运行期间的不同测试集
【发布时间】:2021-01-09 23:08:01
【问题描述】:

由于依赖于本地运行的服务,一部分 pytest 测试无法在 gitlab 上运行。 如何将它们从 gitlab CI 管道中排除,同时保留它们用于本地测试?我不确定是否需要在 pytest、tox 或 gitlab config 中进行过滤。

当前配置:

tox.ini

[testenv]
commands = pytest {posargs}
gitlab-ci.yml


build:
    stage: build
    script:
        - tox

【问题讨论】:

    标签: gitlab pytest tox


    【解决方案1】:

    最方便的方法是通过pytest动态实现

    def test_function():
        if not valid_config():
            pytest.xfail("unsupported configuration")
    

    https://docs.pytest.org/en/latest/skipping.html

    【讨论】:

      【解决方案2】:

      您还可以使用两个不同的tox.ini 文件。

      虽然tox 默认会查找tox.ini,但您也可以传入一个单独的tox.ini 文件,例如...

      tox -c tox-ci.ini
      

      【讨论】:

        猜你喜欢
        • 2016-01-01
        • 1970-01-01
        • 2021-01-15
        • 2014-07-07
        • 2021-09-28
        • 2015-10-24
        • 1970-01-01
        • 2016-05-02
        相关资源
        最近更新 更多