[TIP] Randomizing test order with nose
C. Titus Brown
ctb at msu.edu
Thu Apr 23 08:30:57 PDT 2009
On Thu, Apr 23, 2009 at 08:32:33AM -0700, Scott David Daniels wrote:
-> Douglas Philips wrote:
-> > On or about 2009 Apr 22, at 6:36 PM, Scott David Daniels indited:
-> >> There, the simple expedient of subclassing Random by attaching a
-> >> counter to the root pseudo-random number generator meant that you
-> >> could characterize your position in the random number sequence as
-> >> (_seed, _calls).
-> > ... in previous versions of our attempts to make the PRNG reproducible
-> > we used a counter (and manually called random() to catch up). It was
-> > very tricky to make sure everyone had pulled in the right version of
-> > the instrumented random.
-> > Had we planned for that up front we could have forced the bottleneck
-> > necessary. Instead we've found it was just must simpler to seed the
-> > PRNG to captured and known value, when needed....
->
-> OK, I agree the choke point is a good idea. However, I ran off
-> and 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.
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.
--titus
More information about the testing-in-python
mailing list