Disable individual Python unit tests temporarily Disable individual Python unit tests temporarily python python

Disable individual Python unit tests temporarily


Individual test methods or classes can both be disabled using the unittest.skip decorator.

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

For other options, see the docs for Skipping tests and expected failures.


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@disableddef testFoo():    '''Foo test case'''    print 'this is foo test case'testFoo()

Output:

testFoo has been disabled


Simply placing @unittest.SkipTest decorator above the test is enough.