Fix Python – Disable individual Python unit tests temporarily


Asked By – coelhudo

How can individual unit tests be temporarily disabled when using the unittest module in Python?

Now we will see solution for issue: 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 needed
def test_bar():
    print('This is bar test case.')

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

This question is answered By – yoni

This answer is collected from stackoverflow and reviewed by FixPython community admins, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0