How to fail a python unittest in setUpClass?

self.fail("test") put into your setUp instance method fails all the tests

I think the easiest way to do this at the class level is to make a class variable so something like:

@classmethod
def setUpClass(cls):
   cls.flag = False

def setUp(self):
   if self.flag:
       self.fail("conditions not met")

Hope this is what you want.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)