(One of the summaries of a talk at the 2015 Djangocon EU conference).
Rae Knowler talks about hypothesis. It is a property based testing library inspired by Haskell’s Quickcheck. So: it took out a a bunch of good ideas and you don’t need to know a lot of scary Haskell :-)
The core idea is that it uses randomized data. You tell it to test your login page, for instance, with a name, an age and an email address. It then creates 1000 random names/ages/emails and feeds them to your form.
It simplifies examples of failures. What that means: if it finds an error, it
tries iterating on it, finding out in the end that perhaps your form doesn’t
handle a name with a $
in it. It remembers interesting inputs.
It works with pytest, unittests, everything. It is just a library.
There’s django integration: https://pypi.python.org/pypi/hypothesis-django/ . Custom field types are allowed. It can generate child models. And since last sunday it supports fixtures.
Rae showed a demo. With random numbers, hypothesis reliably found a DivideByZero bug. Nice!
Hypothesis makes discovering this kind of bugs easy. It makes it simple to write tests without having to rigorously figure out the corner cases that break your code.
My name is Reinout van Rees and I program in Python, I live in the Netherlands, I cycle recumbent bikes and I have a model railway.
Most of my website content is in my weblog. You can keep up to date by subscribing to the automatic feeds (for instance with Google reader):