【问题标题】:How to run only one test in tox?如何在 tox 中只运行一项测试?
【发布时间】:2016-02-29 10:34:30
【问题描述】:

我正在尝试为一个项目编写一个新测试,我只想在 tox 中测试那个测试。我已经完全确定其他测试都很好,我不需要每次都运行它们。我发现的唯一一个 suggestion 不适用

ERROR: InvocationError: could not find executable 

【问题讨论】:

    标签: python tox


    【解决方案1】:

    jason meridth所写:

    $ tox -e py35 -- project/tests/test_file.py::TestClassName::test_method
    

    但是在 cmets 中 beluga.me 提到了细粒度:如果您有 tox.ini 文件,您可能需要添加 {posargs} to pytest in tox.ini

    [tox]
    envlist = py35
    
    [testenv]
    deps =
        pytest
        pytest-cov
        pytest-pep8
    commands =
        pip install -e .
        pytest {posargs}
    

    使用 unittest 运行一项测试

    python3 -m unittest -q test_file.TestClassName
    

    【讨论】:

      【解决方案2】:

      运行这个命令:

      tox -epy27 -- test_name
      

      more information

      【讨论】:

      • 我无法使用 tox 2.6 或 2.7 为我完成这项工作,即使使用例如,它也将始终运行所有测试。 tox -e py27-django18 -- idontexistatall
      • 发现了我的问题,应该仔细查看 tox.ini,如果commands = 没有{posargs},它将忽略您添加到命令中的任何内容。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-07-25
      • 1970-01-01
      • 2011-06-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多