[TIP] Randomizing test order with nose

Scott David Daniels Scott.Daniels at Acm.Org
Thu Apr 23 09:14:42 PDT 2009


C. Titus Brown wrote:
> On Thu, Apr 23, 2009 at 08:32:33AM -0700, Scott David Daniels wrote:
> -> ....  I read the random module, and if you can accept a large state, 
> ->you can certainly use .getstate() and .setstate(). The states are
> -> large, so you really want to store them somewhere, rather than retype
> -> them (the advantage of the counter -- it can actually be retyped).
>
> I've been thinking about this for a day or two; I looked at
> getstate/setstate but saw the same problem as you.
>   
The value of a random number generator such as Mersenne Twister is its large
period.  If you reseed it frequently, you limit yourself a small portion of
that space.  The seed size is not enough to address that space.  So if you
are fundamentally relying on randomization to help your testing, you are
eliminating most of your search space a priori.  That is, of course, more
a theory argument, and I can just use my separate code instead.

> What about just setting the seed yourself, before each test, and then
> storing that?  You have the problem of generating a "new" seed, but you
> could easily do that by using the time + # of test, or some such.
>   
I have looked at the underlying code for Mersenne Twister, and I think I see
how to submit a patch that can produce a smaller state. A block advance and
individual advance are run, so I am thinking get_small_state may return a
triple or so.  If we combine a version (as the getstate does), we can leave
it pretty small.  Of course, this is a cursory look, I have not thought the
implications through (e.g. does it force a change to base getstate?).

--Scott David Daniels

Scott.Daniels at Acm.Org





More information about the testing-in-python mailing list