home *** CD-ROM | disk | FTP | other *** search
/ Komputer for Alle 2004 #2 / K-CD-2-2004.ISO / OpenOffice Sv / f_0397 / python-core-2.2.2 / lib / test / test_random.py < prev    next >
Encoding:
Text File  |  2003-07-18  |  550 b   |  20 lines

  1. import test_support
  2. import random
  3.  
  4. # Ensure that the seed() method initializes all the hidden state.  In
  5. # particular, through 2.2.1 it failed to reset a piece of state used by
  6. # (and only by) the .gauss() method.
  7.  
  8. for seed in 1, 12, 123, 1234, 12345, 123456, 654321:
  9.     for seeder in random.seed, random.whseed:
  10.         seeder(seed)
  11.         x1 = random.random()
  12.         y1 = random.gauss(0, 1)
  13.  
  14.         seeder(seed)
  15.         x2 = random.random()
  16.         y2 = random.gauss(0, 1)
  17.  
  18.         test_support.vereq(x1, x2)
  19.         test_support.vereq(y1, y2)
  20.