python - 暂时禁用单个 Python 单元测试

标签 python python-unittest

在 Python 中使用 unittest 模块时如何暂时禁用单个单元测试?

最佳答案

可以使用 unittest.skip 禁用单独的测试方法或类。装饰器。

@unittest.skip("reason for skipping")
def test_foo():
    print('This is foo test case.')


@unittest.skip  # no reason needed
def test_bar():
    print('This is bar test case.')

有关其他选项,请参阅 Skipping tests and expected failures 的文档.

关于python - 暂时禁用单个 Python 单元测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2066508/

相关文章:

python - 通过列表列表递归 "all paths"- Python

python - 使用正则表达式从字符串中提取子字符串

python - 使用unittest和Python 3.6导入时出错

python - unittest.TestCase 获取 `TypeError: Error when calling the metaclas bases __init__() takes exactly 2 arguments (4 given)`

python - 通过数据库调用对数据分析进行单元测试的最佳方法

python - Django 应用程序中缺少 runTest 函数

python - View 不适用于转置数组

python - 无法使用 python 中的 fracdiff.sim 和 arfima.sim - 'DocumentedSTFunction' 对象没有属性 'sim'

python : string split with either A or B

python - 如何在表驱动测试中使用assertRaises,其中一些测试会引发而其他测试则不会