Reputation:
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?
Upvotes: 4
Views: 7829
Reputation: 346
I had a slightly different problem: if var
was either 'a'
or 'b'
I used assertIn(var, {'a', 'b'})
Upvotes: 4
Reputation: 6488
You could use assertTrue
:
assertTrue(var == 'a' or var2 == 'a')
Upvotes: 10