diff options
author | Raymond Hettinger <python@rcn.com> | 2003-01-05 01:08:34 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2003-01-05 01:08:34 (GMT) |
commit | 15ec3731cfd24cb2a7be60db849f3588536eff98 (patch) | |
tree | 2a5cfa261fa8d593deec77f86a30ce9bd41b8837 | |
parent | 5bd844e20f7faf4c9c7c9eda6b92ba48a44af33c (diff) | |
download | cpython-15ec3731cfd24cb2a7be60db849f3588536eff98.zip cpython-15ec3731cfd24cb2a7be60db849f3588536eff98.tar.gz cpython-15ec3731cfd24cb2a7be60db849f3588536eff98.tar.bz2 |
Add a test case.
-rw-r--r-- | Lib/test/test_random.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/Lib/test/test_random.py b/Lib/test/test_random.py index b5fe1e5..d917281 100644 --- a/Lib/test/test_random.py +++ b/Lib/test/test_random.py @@ -182,6 +182,24 @@ class MersenneTwister_TestBasicOps(TestBasicOps): seed = (1L << (10000 * 8)) - 1 # about 10K bytes self.gen.seed(seed) +class TestDistributions(unittest.TestCase): + def test_zeroinputs(self): + # Verify that distributions can handle a series of zero inputs' + g = random.Random() + x = [g.random() for i in xrange(50)] + [0.0]*5 + g.random = x[:].pop; g.uniform(1,10) + g.random = x[:].pop; g.paretovariate(1.0) + g.random = x[:].pop; g.expovariate(1.0) + g.random = x[:].pop; g.weibullvariate(1.0, 1.0) + g.random = x[:].pop; g.normalvariate(0.0, 1.0) + g.random = x[:].pop; g.gauss(0.0, 1.0) + g.random = x[:].pop; g.lognormvariate(0.0, 1.0) + g.random = x[:].pop; g.vonmisesvariate(0.0, 1.0) + g.random = x[:].pop; g.gammavariate(0.01, 1.0) + g.random = x[:].pop; g.gammavariate(1.0, 1.0) + g.random = x[:].pop; g.gammavariate(200.0, 1.0) + g.random = x[:].pop; g.betavariate(3.0, 3.0) + class TestModule(unittest.TestCase): def testMagicConstants(self): self.assertAlmostEqual(random.NV_MAGICCONST, 1.71552776992141) @@ -199,6 +217,7 @@ def test_main(): suite = unittest.TestSuite() for testclass in (WichmannHill_TestBasicOps, MersenneTwister_TestBasicOps, + TestDistributions, TestModule): suite.addTest(unittest.makeSuite(testclass)) test_support.run_suite(suite) |