how to test when correct output is "random"?
Skip Montanaro
skip at pobox.com
Fri Apr 4 17:02:08 EST 2003
Jeff> I'd like to use this project as an opportunity to teach myself
Jeff> something about testing methodology, but since the output is based
Jeff> on a random number generator, how can the normal "unit test" or
Jeff> "doctest" tools work for me?
Seed the rng with the same starting value. I believe you will always get
the same sequence:
>>> random.seed(42)
>>> random.random()
0.63942679845788375
>>> random.random()
0.025010755222666936
>>> random.random()
0.27502931836911926
>>> random.seed(42)
>>> random.random()
0.63942679845788375
>>> random.random()
0.025010755222666936
>>> random.random()
0.27502931836911926
Skip
More information about the Python-list
mailing list