nosetests 通过多项测试跳过 python 中的某些测试

nosetests skip certain tests in python with multiple tests

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

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

假设有大约 30 tests 并且在 5 之外我想跳过-为此我正在尝试

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

任何帮助都会很棒!!

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

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