Unit test in Python, error in setup class -
i writing test suite as:
class mysuite(unnitest.testcase): @classmethod def setupclass(cls): try: ***some code throw exception*** except exception e: print('error thrown') @classmethod def teardownclass(cls): print('in teardown') def test_demo(self): print('in test_demo')
the problem is, though error thrown in setup (because of 5/0), test_demo executed, not want to.
what best approach stop executing test_demo whenever there error in setup method.
you're catching error , printing message in response. don't that.
if want print something, @ least re-raise exception afterwards. better not bother catching @ all: traceback should sufficient information.
(also, first parameter classmethod called cls
not self
, class itself.)
Comments
Post a Comment