python - How to test if a function runs without failure or returns a specific value -


i need test whether function runs without failure or test whether value returned 1 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 run when there single ballot 0 votes') 

i'd recommend using assertin, you're checking if value 1 of 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 run when there single ballot 0 votes') 

see docs full details.


Comments

Popular posts from this blog

routing - AngularJS State management ->load multiple states in one page -

python - GRASS parser() error -

Swift game error message -