yon*_*oni 202
可以使用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.')
Run Code Online (Sandbox Code Playgroud)
有关其他选项,请参阅跳过测试和预期失败的文档.
小智 26
您可以使用装饰器来禁用可以包装该函数的测试,并阻止googletest或python单元测试运行测试用例.
def disabled(f):
def _decorator():
print f.__name__ + ' has been disabled'
return _decorator
@disabled
def testFoo():
'''Foo test case'''
print 'this is foo test case'
testFoo()
Run Code Online (Sandbox Code Playgroud)
输出:
testFoo has been disabled
Run Code Online (Sandbox Code Playgroud)
Nou*_*him 11
最新版本(2.7 - 未发布)支持测试跳过/禁用.您可以获得此模块并在现有的Python安装上使用它.它可能会奏效.
在此之前,我曾经改名,我想跳过来测试xtest_testname从test_testname.
这是一个快速的elisp脚本来执行此操作.我的elisp有点生疏,所以我提前为它遇到的任何问题道歉.未经测试.
(defun disable_enable_test ()
(interactive "")
(save-excursion
(beginning-of-line)
(search-forward "def")
(forward-char)
(if (looking-at "disable_")
(zap-to-char 1 ?_)
(insert "disable_"))))
Run Code Online (Sandbox Code Playgroud)