【问题标题】:Python tox deps with patterned commands带有模式命令的 Python tox deps
【发布时间】:2019-03-20 17:14:17
【问题描述】:

我正在使用tox 进行测试。目前我的tox.ini 定义了几个命令:

commands =
    unit-a: py.test --cov mypackage mypackage/tests/unit/a []
    unit-b: py.test --cov mypackage mypackage/tests/unit/b []
    func: python -m behave -n "{env:SCENARIO}"

它还定义了每个命令的依赖关系:

deps =
    unit-a: mock
    unit-a: pytest==3.9.3
    unit-a: pytest-cov
    unit-a: pytest-sugar
    unit-b: mock
    unit-b: pytest==3.9.3
    unit-b: pytest-cov
    unit-b: pytest-sugar
    func: behave

这对我来说既笨重又多余。有没有办法使用命令模式来指定deps?例如,

deps =
    unit-*: mock
    unit-*: pytest==3.9.3
    unit-*: pytest-cov
    unit-*: pytest-sugar
    func: behave

这是我在尝试时遇到的错误:

ERROR: invocation failed (exit code 1), logfile: /app/.tox/py3-unit-a/log/py3-unit-a.log
ERROR: actionid: py3-unit-a
msg: getenv
cmdargs: "/app/.tox/py3-unit-a/bin/pip install --progress-bar off --index-url=https://pypi.org/simple 'unit-*: mock' 'unit-*: pytest==3.9.3' 'unit-*: pytest-cov' 'unit-*: pytest-sugar'"

Invalid requirement: 'unit-*: mock'

【问题讨论】:

    标签: python unit-testing tox


    【解决方案1】:

    你可以这样做:

    deps =
        unit: mock pytest==3.9.3 pytest-cov pytest-sugar
        func: behave
    

    unit: 的第一行有效,因为 tox splits factors by -

    你也可以尝试否定:

    deps =
        !func: mock pytest==3.9.3 pytest-cov pytest-sugar
        func: behave
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-11-17
      • 2011-07-11
      • 1970-01-01
      • 2021-11-25
      • 1970-01-01
      • 1970-01-01
      • 2010-12-02
      • 1970-01-01
      相关资源
      最近更新 更多