I am having little trouble using the python setUpClass.
For example consider the following case
class MyTest(unittest.case.TestCase):
@classmethod
def setUpClass(cls):
print "Test setup"
try:
1/0
except:
raise
@classmethod
def tearDownClass(cls):
print "Test teardown"
A couple of questions
Is the above code the right way to handle test setUpClass exceptions (by raising it so that the python unittest can take care of it), there are fail(), skip() methods, but those can only be used by test instances and not the test classes.
When there is a setUpClass exception, how can we ensure that tearDownClass runs (unittest doesn't run it, should we manualy call it).
except: raisedoes nothing. (Except maybe mess up the stack trace, not sure.) You might as well leave the wholetry..exceptblock out.try..except(like the one you have) to calltearDownClasson an exception. After that, you could reraise the exception.raise.