summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2008-01-13 23:40:30 (GMT)
committerRaymond Hettinger <python@rcn.com>2008-01-13 23:40:30 (GMT)
commit28de64fd0fe45475e6d2263eec25c3d19c00074b (patch)
treed34ee792cd1e4cdc25cfc8bf3304b2ffd7521e80 /Lib/test
parentf7ec7a81a557947fff5cb02510e121e8219e7811 (diff)
downloadcpython-28de64fd0fe45475e6d2263eec25c3d19c00074b.zip
cpython-28de64fd0fe45475e6d2263eec25c3d19c00074b.tar.gz
cpython-28de64fd0fe45475e6d2263eec25c3d19c00074b.tar.bz2
Remove defunct parts of the random module
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_generators.py44
-rw-r--r--Lib/test/test_random.py64
2 files changed, 23 insertions, 85 deletions
diff --git a/Lib/test/test_generators.py b/Lib/test/test_generators.py
index b6d2ec0..892535d 100644
--- a/Lib/test/test_generators.py
+++ b/Lib/test/test_generators.py
@@ -444,7 +444,7 @@ Subject: Re: PEP 255: Simple Generators
>>> roots = sets[:]
>>> import random
->>> gen = random.WichmannHill(42)
+>>> gen = random.Random(42)
>>> while 1:
... for s in sets:
... print(" %s->%s" % (s, s.find()), end='')
@@ -458,29 +458,29 @@ Subject: Re: PEP 255: Simple Generators
... else:
... break
A->A B->B C->C D->D E->E F->F G->G H->H I->I J->J K->K L->L M->M
-merged D into G
- A->A B->B C->C D->G E->E F->F G->G H->H I->I J->J K->K L->L M->M
-merged C into F
- A->A B->B C->F D->G E->E F->F G->G H->H I->I J->J K->K L->L M->M
+merged I into A
+ A->A B->B C->C D->D E->E F->F G->G H->H I->A J->J K->K L->L M->M
+merged D into C
+ A->A B->B C->C D->C E->E F->F G->G H->H I->A J->J K->K L->L M->M
+merged K into H
+ A->A B->B C->C D->C E->E F->F G->G H->H I->A J->J K->H L->L M->M
merged L into A
- A->A B->B C->F D->G E->E F->F G->G H->H I->I J->J K->K L->A M->M
-merged H into E
- A->A B->B C->F D->G E->E F->F G->G H->E I->I J->J K->K L->A M->M
-merged B into E
- A->A B->E C->F D->G E->E F->F G->G H->E I->I J->J K->K L->A M->M
+ A->A B->B C->C D->C E->E F->F G->G H->H I->A J->J K->H L->A M->M
+merged E into A
+ A->A B->B C->C D->C E->A F->F G->G H->H I->A J->J K->H L->A M->M
+merged B into G
+ A->A B->G C->C D->C E->A F->F G->G H->H I->A J->J K->H L->A M->M
+merged A into F
+ A->F B->G C->C D->C E->F F->F G->G H->H I->F J->J K->H L->F M->M
+merged H into G
+ A->F B->G C->C D->C E->F F->F G->G H->G I->F J->J K->G L->F M->M
+merged F into J
+ A->J B->G C->C D->C E->J F->J G->G H->G I->J J->J K->G L->J M->M
+merged M into C
+ A->J B->G C->C D->C E->J F->J G->G H->G I->J J->J K->G L->J M->C
merged J into G
- A->A B->E C->F D->G E->E F->F G->G H->E I->I J->G K->K L->A M->M
-merged E into G
- A->A B->G C->F D->G E->G F->F G->G H->G I->I J->G K->K L->A M->M
-merged M into G
- A->A B->G C->F D->G E->G F->F G->G H->G I->I J->G K->K L->A M->G
-merged I into K
- A->A B->G C->F D->G E->G F->F G->G H->G I->K J->G K->K L->A M->G
-merged K into A
- A->A B->G C->F D->G E->G F->F G->G H->G I->A J->G K->A L->A M->G
-merged F into A
- A->A B->G C->A D->G E->G F->A G->G H->G I->A J->G K->A L->A M->G
-merged A into G
+ A->G B->G C->C D->C E->G F->G G->G H->G I->G J->G K->G L->G M->C
+merged C into G
A->G B->G C->G D->G E->G F->G G->G H->G I->G J->G K->G L->G M->G
"""
diff --git a/Lib/test/test_random.py b/Lib/test/test_random.py
index 6adcd06..a7fe605 100644
--- a/Lib/test/test_random.py
+++ b/Lib/test/test_random.py
@@ -42,21 +42,6 @@ class TestBasicOps(unittest.TestCase):
self.assertRaises(TypeError, self.gen.seed, 1, 2)
self.assertRaises(TypeError, type(self.gen), [])
- def test_jumpahead(self):
- self.gen.seed()
- state1 = self.gen.getstate()
- self.gen.jumpahead(100)
- state2 = self.gen.getstate() # s/b distinct from state1
- self.assertNotEqual(state1, state2)
- self.gen.jumpahead(100)
- state3 = self.gen.getstate() # s/b distinct from state2
- self.assertNotEqual(state2, state3)
-
- self.assertRaises(TypeError, self.gen.jumpahead) # needs an arg
- self.assertRaises(TypeError, self.gen.jumpahead, "ick") # wrong type
- self.assertRaises(TypeError, self.gen.jumpahead, 2.3) # wrong type
- self.assertRaises(TypeError, self.gen.jumpahead, 2, 3) # too many
-
def test_sample(self):
# For the entire allowable range of 0 <= k <= N, validate that
# the sample is of the correct length and contains only unique items
@@ -157,48 +142,6 @@ class TestBasicOps(unittest.TestCase):
f.close()
self.assertEqual(r.randrange(1000), value)
-class WichmannHill_TestBasicOps(TestBasicOps):
- gen = random.WichmannHill()
-
- def test_setstate_first_arg(self):
- self.assertRaises(ValueError, self.gen.setstate, (2, None, None))
-
- def test_strong_jumpahead(self):
- # tests that jumpahead(n) semantics correspond to n calls to random()
- N = 1000
- s = self.gen.getstate()
- self.gen.jumpahead(N)
- r1 = self.gen.random()
- # now do it the slow way
- self.gen.setstate(s)
- for i in range(N):
- self.gen.random()
- r2 = self.gen.random()
- self.assertEqual(r1, r2)
-
- def test_gauss_with_whseed(self):
- # Ensure that the seed() method initializes all the hidden state. In
- # particular, through 2.2.1 it failed to reset a piece of state used
- # by (and only by) the .gauss() method.
-
- for seed in 1, 12, 123, 1234, 12345, 123456, 654321:
- self.gen.whseed(seed)
- x1 = self.gen.random()
- y1 = self.gen.gauss(0, 1)
-
- self.gen.whseed(seed)
- x2 = self.gen.random()
- y2 = self.gen.gauss(0, 1)
-
- self.assertEqual(x1, x2)
- self.assertEqual(y1, y2)
-
- def test_bigrand(self):
- # Verify warnings are raised when randrange is too large for random()
- with test_support.catch_warning():
- warnings.filterwarnings("error", "Underlying random")
- self.assertRaises(UserWarning, self.gen.randrange, 2**60)
-
class SystemRandom_TestBasicOps(TestBasicOps):
gen = random.SystemRandom()
@@ -214,10 +157,6 @@ class SystemRandom_TestBasicOps(TestBasicOps):
# Doesn't need to do anything except not fail
self.gen.seed(100)
- def test_jumpahead(self):
- # Doesn't need to do anything except not fail
- self.gen.jumpahead(100)
-
def test_gauss(self):
self.gen.gauss_next = None
self.gen.seed(100)
@@ -541,8 +480,7 @@ class TestModule(unittest.TestCase):
def test_main(verbose=None):
- testclasses = [WichmannHill_TestBasicOps,
- MersenneTwister_TestBasicOps,
+ testclasses = [MersenneTwister_TestBasicOps,
TestDistributions,
TestModule]