I work on a set of python unit tests that are currently built using pythons built in testing framework. I would like to write paramaterized tests that will execute multiple times based on the set of data I give it.
ie. if my data set is [1,2,3,4] my test function would run four times using the input in my data set.
def test(data):
if data > 0:
#Pass the test
From my understanding this isn’t possible currently in the built in framework, unless I put a loop in my test function. I don’t want to do this because I need the test to continue executing even if one input fails.
I’ve seen that it’s possible to do using nose, or pyTest. Which is the best framework to use? Is there another framework I could use that would be better than either of these?
Thanks in advance!
Note that this is precisely one of the most common uses of the recent addition of funcargs in py.test.
In your case you’d get:
[EDIT] I should probably add that you can also do that as simply as
So I’d say that py.test is a great framework for parameterized unit testing…