How to disable individual tests temporarily using unittest module in python?
Thanks.
How to disable individual tests temporarily using unittest module in python?
Thanks.
The docs for 2.1 don't specify an ignore or skip method.
Usually though, I block comment when needed.
The latest version (2.7 - unreleased) supports test skipping/disabling like so. You could just get this module and use it on your existing Python install. It will probably work.
Before this, I used to rename the tests I wanted skipped to xtest_testname
from test_testname
.
Here's a quick elisp script to do this. My elisp is a little rusty so I apologise in advance for any problems it has. Untested.
(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_"))))
You can use decorators to disable the test that can wrap the function and prevent the googletest or python unit test to run the testcase.
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()
Output:
testFoo has been disabled
I just rename a test case method with an underscore: test_myfunc becomes _test_myfunc.