haypo/python-ipy — pull request #26 by djmitche (2014-08-26 02:44:58+00:00)
Title: Add fuzz testing

#25 unveils a pretty serious error, for a library that should be pretty nearly always correct.

It's pretty trivial to automatically invent test cases for a library like this. For `__contains__`, for example, it'd be easy to generate a list of random IP prefixes, then either pick a query prefix that's within one of those prefixes, or that is *not* within one of them. Then call `__contains__` and verify it returns True or False, respectively.

Running a few hundred iterations of this on every run of the tests would, eventually, find errors of this sort. Especially if it runs in travis :)