In a previous life I did a fair bit of Java development, and found JUnit Theories to be quite useful. Is there any similar mechanism for Python?
Currently I'm doing something like:
def some_test(self):
cases = [('some sample input', 'some expected value'),
('some other input', 'some other expected value')]
for value, expected in cases:
result = method_under_test(value)
self.assertEqual(expected, result)
But this is rather clunky, if the first "case" fails, all others fail to be run.
Aucun commentaire:
Enregistrer un commentaire