mercredi 22 avril 2015

Python unittest - multiple assertions => don't fail if at least of one them passes

I'm doing that at the moment:

try:
    self.assertIsNotNone(a)
except AssertionError:
    try:
        self.assertIsNotNone(b)
    except AssertionError:
        try:
            self.assertIsNotNone(c)
        except AssertionError:
            self.assertIsNotNone(d)

(any of these assertions should pass)

How to do that better?

Aucun commentaire:

Enregistrer un commentaire