summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2010-09-07 15:00:15 (GMT)
committerRaymond Hettinger <python@rcn.com>2010-09-07 15:00:15 (GMT)
commitc585eecfb0384a9c6b560477c1f04c43b55cc8e3 (patch)
treeb16d3c947ff6cf24ade3fe247100c21b71fbfd90
parenta300007c6e047bfdd7ab8f9bef35c0929d7dbbc8 (diff)
downloadcpython-c585eecfb0384a9c6b560477c1f04c43b55cc8e3.zip
cpython-c585eecfb0384a9c6b560477c1f04c43b55cc8e3.tar.gz
cpython-c585eecfb0384a9c6b560477c1f04c43b55cc8e3.tar.bz2
Fix test that depends on a particular implementation of random.choice().
-rw-r--r--Lib/random.py7
-rw-r--r--Lib/test/test_generators.py44
2 files changed, 24 insertions, 27 deletions
diff --git a/Lib/random.py b/Lib/random.py
index 0886562..e0c56db 100644
--- a/Lib/random.py
+++ b/Lib/random.py
@@ -136,7 +136,7 @@ class Random(_random.Random):
# really unsigned 32-bit ints, so we convert negative ints from
# version 2 to positive longs for version 3.
try:
- internalstate = tuple( x % (2**32) for x in internalstate )
+ internalstate = tuple(x % (2**32) for x in internalstate)
except ValueError as e:
raise TypeError from e
super(Random, self).setstate(internalstate)
@@ -214,10 +214,7 @@ class Random(_random.Random):
def _randbelow(self, n, int=int, _maxwidth=1<<BPF, type=type,
_Method=_MethodType, _BuiltinMethod=_BuiltinMethodType):
- """Return a random int in the range [0,n)
-
- Handles the case where n has more bits than returned
- by a single call to the underlying generator.
+ """Return a random int in the range [0,n). Raises ValueError if n==0.
"""
getrandbits = self.getrandbits
diff --git a/Lib/test/test_generators.py b/Lib/test/test_generators.py
index 90af15b..3ec209b 100644
--- a/Lib/test/test_generators.py
+++ b/Lib/test/test_generators.py
@@ -458,30 +458,30 @@ 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 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->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 K into B
+ A->A B->B C->C D->D E->E F->F G->G H->H I->I J->J K->B L->L 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
+ A->F B->B C->C D->D E->E F->F G->G H->H I->I J->J K->B L->L M->M
+merged E into F
+ A->F B->B C->C D->D E->F F->F G->G H->H I->I J->J K->B L->L M->M
+merged D into C
+ A->F B->B C->C D->C E->F F->F G->G H->H I->I J->J K->B L->L 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->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
+ A->F B->B C->C D->C E->F F->F G->G H->H I->I J->J K->B L->L M->C
+merged J into B
+ A->F B->B C->C D->C E->F F->F G->G H->H I->I J->B K->B L->L M->C
+merged B into C
+ A->F B->C C->C D->C E->F F->F G->G H->H I->I J->C K->C L->L M->C
+merged F into G
+ A->G B->C C->C D->C E->G F->G G->G H->H I->I J->C K->C L->L M->C
+merged L into C
+ A->G B->C C->C D->C E->G F->G G->G H->H I->I J->C K->C L->C M->C
+merged G into I
+ A->I B->C C->C D->C E->I F->I G->I H->H I->I J->C K->C L->C M->C
+merged I into H
+ A->H B->C C->C D->C E->H F->H G->H H->H I->H J->C K->C L->C M->C
+merged C into H
+ A->H B->H C->H D->H E->H F->H G->H H->H I->H J->H K->H L->H M->H
"""
# Emacs turd '