diff options
author | Raymond Hettinger <python@rcn.com> | 2010-09-07 04:44:52 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2010-09-07 04:44:52 (GMT) |
commit | 0515661314c4e5b9235e07b2c46b8f456c7fadc3 (patch) | |
tree | b8f06b2f3a9d5f9d99b91de02052f9bf38f6aff7 /Lib/test/test_random.py | |
parent | 3051cc3a0d390ba153c07db9ce31a44700e332f2 (diff) | |
download | cpython-0515661314c4e5b9235e07b2c46b8f456c7fadc3.zip cpython-0515661314c4e5b9235e07b2c46b8f456c7fadc3.tar.gz cpython-0515661314c4e5b9235e07b2c46b8f456c7fadc3.tar.bz2 |
Issues #7889, #9025 and #9379: Improvements to the random module.
Diffstat (limited to 'Lib/test/test_random.py')
-rw-r--r-- | Lib/test/test_random.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/Lib/test/test_random.py b/Lib/test/test_random.py index 78cd4d5..f5c0030 100644 --- a/Lib/test/test_random.py +++ b/Lib/test/test_random.py @@ -121,7 +121,15 @@ class TestBasicOps(unittest.TestCase): f = open(support.findfile(file),"rb") r = pickle.load(f) f.close() - self.assertEqual(r.randrange(1000), value) + self.assertEqual(int(r.random()*1000), value) + + def test_bug_9025(self): + # Had problem with an uneven distribution in int(n*random()) + # Verify the fix by checking that distributions fall within expectations. + n = 100000 + randrange = self.gen.randrange + k = sum(randrange(6755399441055744) % 3 == 2 for i in range(n)) + self.assertTrue(0.30 < k/n < .37, (k/n)) class SystemRandom_TestBasicOps(TestBasicOps): gen = random.SystemRandom() |