Providing test data in Python

Viewed 14388

How can I run the same test against a lot of different data?

I want to be reported of all failures.

For example:

def isEven(number):
    return True # Quite buggy implementation

data = [
    (2, True),
    (3, False),
    (4, True),
    (5, False),
]

class MyTest:
   def evenTest(self, num, expected):
       self.assertEquals(expected, isEven(num))

I have found solution which raises error on first failure only: PHPUnit style dataProvider in Python unit test

How can I run a test to be reported of all failures?

5 Answers
Related