暂时禁用单独的Python单元测试
本教程将介绍暂时禁用单独的Python单元测试的处理方法,这篇教程是从别的地方看到的,然后加了一些国外程序员的疑问与解答,希望能对你有所帮助,好了,下面开始学习吧。
问题描述
在使用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单元测试的教程就到这里就结束了,希望趣模板源码网找到的这篇技术文章能帮助到大家,更多技术教程可以在站内搜索。