【问题标题】:nosetests skip certain tests in python with multiple tests鼻子测试通过多个测试跳过python中的某些测试
【发布时间】:2019-04-04 10:15:08
【问题描述】:

我想从构建或管道中跳过或排除某些特定测试。

我正在运行nosetests -s -v *,它在某个特定文件夹下运行所有​​测试。

假设有大约30 tests5 我想跳过- 为此我正在尝试

nosetests -s -v * --exclude-test test_sometest.py test_somemoretest.py

nosetests -s -v * -- test_sometest.py test_somemoretest.py

但它们都对我不起作用。

I am referring from here

#!/bin/sh

cd tests/engine_tests/measures

nosetests -s -v * --exclude-test test_sometest1.py test_somemoretest2.py test_sometest3.py test_somemoretest4.py

任何帮助都会很棒!

【问题讨论】:

标签: shell command-line build pipeline nose


【解决方案1】:

将此参数添加到您的命令中: --ignore-files="tests_to_exclude\.py"

【讨论】:

  • 如何添加多个
  • 你的意思是这个!!! nosetests -s -v * --ignore-files="test1.py", "test2.py", "test3.py"
  • 尝试转义.
  • 详细的,请!
  • 运行 nosetests -s -v * --ignore-files="test1\.py" 并检查它没有运行 test1.py
【解决方案2】:
python -m pytest --cache-clear -v -x -r a --junit-xml=tests/engine_tests --junit-prefix=measure_tests *.py --deselect Test1\.py --deselect Test2\.py --deselect Test3\.py --deselect Test4\.py

我试过这个,它对我有用。在此之前你需要安装pytest

pip install pytest

文档将通过键入找到 终端下pytest --help

或某处here

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-02
    • 1970-01-01
    相关资源
    最近更新 更多