jeudi 4 juin 2015

Python unittest, do something only if test fails

When using the unittest library from python 3 I would like to do some actions only if a test fails (but this should be on a class level so I don't have to write it for each test). For example when using behave there was something like:

def after_step(context, step):
    if step.status == "failed":
        ...

Is there something similar for the unittestlibrary and if not, what would be the easiest approach to do something similar?

Aucun commentaire:

Enregistrer un commentaire