QuickCheck.py?

QuickCheck is pretty handy Haskell module. It basically generates test data and tests your code. Pretty useful, right?

Now, this is Haskell so it is pretty magical even though you do actually still need to write your own tests (they are called properties in the Haskell world).

A property is basically a function that tests the function you are interested in testing =)
You define what sort of arguments it takes and write the property in such a way so that it returns True if it worked as expected and False otherwise.

Why don’t we have this for Python? Do we? I mean, how hard is it really to write a higher order function that takes a method as input. Looks at the method, generates 100 different input combinations and then tries them all? If any of them fail, the test fails and it will let you know what input cause it to break.

There are no guarantees that the function is OK after the QuickCheck test have passed but you can be pretty darn confident that it is OK. It finds your bugs for you. In the end, isn’t that what we really need?

Advertisements