I have the following code for test class. Looks like teardown_class does not get invoked when exception is raised in setup_class. How can I make teardown_class run even if exception appears in setup_class?
import unittest
class LoginTests(unittest.TestCase):
@classmethod
def setup_class(cls):
print("setup_class")
raise Exception("ex")
def test_01_login_with_valid_password(self):
pass
@classmethod
def teardown_class(cls):
print("teardown_class")
if __name__ == "__main__":
unittest.main()