python - setup_class引发异常时如何跳过所有测试用例
问题描述
如果 setup_class 发生异常,有谁知道如何跳过测试套件?我有如下代码
import pytest
#@pytest.mark.skip(reason='skip if testsuite') #i can put skip here to skip all TestSuite
class TestSuite():
@classmethod
def setup_class(cls):
try:
raise Exception(f'can not find suitable strategy: {e}')
except Exception as a:
#I want to skip the testsuite for all testcase
def test_func1(self):
pass
def test_func2(self):
pass
def test_func3(self):
pass
解决方案
http://doc.pytest.org/en/latest/skipping.html
你可以把它放在你的异常块中:
pytest.skip("failed to complete setup")
推荐阅读
- f# - 将选项 val 更改为(val | DefaultType 的特殊类型)
- typo3 - 在打字稿设置中使用带有空格的SplitProcessor作为分隔符?
- postgresql - 在 postgres 列中查找任何数组
- mysql - MySQL 根据该随机值更新具有随机值和条件值的 2 列
- r - 如何找到相似字符串之间的差异?
- shell - 我在自己安装了 6.7 版本后安装了 5.1.6-1 dse cassandra
- r - 在R中使用download.file之前如何检查url中是否存在文件
- python-3.x - 将时间戳转换为日期应用于 Python 中的多个列
- c++ - 无法使用 Qt Creator 在 Windows 中构建 yaml-cpp
- javascript - 上传多个文件并显示进度条