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?
You could use assertTrue
:
assertTrue(var == 'a' or var2 == 'a')
I had a slightly different problem: if var
was either 'a'
or 'b'
I used assertIn(var, {'a', 'b'})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With