[TIP] Using randomic tests

Yoni Tsafir yonix85 at gmail.com
Mon Nov 15 08:20:58 PST 2010


Hi there,
I like writing tests that use a lot of random values as input.

Something I found useful during my experience in other languages, is to have
some kind of test runner that prints the initial random seed when a test
fails, and lets you run your tests with the same random seed again so you
can debug it and tell why the test failed with this particular seed.
This of course forces your tests to use a the singleton instance of random
instead of instantiating new classes of "random.Random" (or maybe use
another singleton random object).

Now, before I start writing this mechanism in python as well, I was
wondering if there is anything already implemented in this area (maybe some
kind of nose's hidden feature or something), or any other suggestions of
ways to achieve what I'm seeking after.

Thanks!
Yoni.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20101115/f32531d6/attachment.htm>


More information about the testing-in-python mailing list