Reputation: 13
I just need to test whether the function runs without failure or test whether the value returned is one of:
('NDP', None) or ('CPC', None) or ('GREEN', None) or ('LIBERAL', None)
def test_single_zero_ballot(self):
self.assertEqual(voting_systems.voting_irv({('NDP','CPC','LIBERAL','GREEN'):0}),
(('NDP', None) or ('CPC', None) or ('GREEN', None) or ('LIBERAL', None)),
'Fails to run when there is a single ballot with zero votes')
Upvotes: 1
Views: 72
Reputation: 9899
I'd recommend using assertIn
, as you're checking if the value is one of a few values:
def test_single_zero_ballot(self):
valid_values = [('NDP', None), ('CPC', None), ('GREEN', None), ('LIBERAL', None)]
self.assertIn(voting_systems.voting_irv({('NDP','CPC','LIBERAL','GREEN'):0}),
valid_values,
'Fails to run when there is a single ballot with zero votes')
See the docs for the full details.
Upvotes: 1