I am writing a test suite as:
class MySuite(unnitest.Testcase):
@classmethod
def setUpclass(cls):
try:
***some code which will throw exception***
except Exception as e:
print('Error Thrown')
@classmethod
def tearDownClass(cls):
print('In teardown')
def test_demo(self):
print('In test_demo')
The problem is, though error will be thrown in setup (because of 5/0), the test_demo will be executed, which I do not want to.
What could be the best approach to stop executing the test_demo whenever there is an error in setup method.
try-exceptin your setup, and just allow the exception to propagate?