vendredi 5 février 2016

Python unittest conditional assert

I need to test if either assertEqual(var, 'a') or assertEqual(var2, 'a') is true.

I can't just write them like:

assertEqual(var, 'a')
assertEqual(var2, 'a')

because that's not the scope of the test. The test should succeed whether var = 'a' or var2 = 'a', but in this case if for instance var2 = 'b' it will fail.

So how could I write this test? Because if I use if assertEqual(var, 'a') or assertEqual(var2, 'a'):, what should I type inside?

Aucun commentaire:

Enregistrer un commentaire