how to test when correct output is "random"?

Gerhard Häring gh at ghaering.de
Fri Apr 4 17:03:25 EST 2003


* Jeff Epler <jepler at unpythonic.net> [2003-04-04 15:53 -0600]:
> My current project, Novelwriting[1] is a knock-off of something called
> the Dada Engine[2].  Essentially, you write a file that describes the
> structure of a document, and Novelwriting outputs a document that
> matches the structure.
> 
> I'd like to use this project as an opportunity to teach myself something
> about testing methodology, but since the output is based on a random
> number generator, how can the normal "unit test" or "doctest" tools work
> for me? [...]

As you don't want to test the quality of the PRNG, how about using a
custom PRNG that is *not random*, but *predictable* in the unit test?

Gerhard
-- 
mail:   gh at ghaering.de
web:    http://ghaering.de/





More information about the Python-list mailing list