8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0f866cb commit 5ae669fCopy full SHA for 5ae669f
Lib/test/test_random.py
@@ -14,6 +14,15 @@
14
from fractions import Fraction
15
from collections import abc, Counter
16
17
+
18
+class MyIndex:
19
+ def __init__(self, value):
20
+ self.value = value
21
22
+ def __index__(self):
23
+ return self.value
24
25
26
class TestBasicOps:
27
# Superclass with tests common to all generators.
28
# Subclasses must arrange for self.gen to retrieve the Random instance
@@ -809,6 +818,9 @@ def test_getrandbits(self):
809
818
self.gen.seed(1234567)
810
819
self.assertEqual(self.gen.getrandbits(100),
811
820
97904845777343510404718956115)
821
+ self.gen.seed(1234567)
822
+ self.assertEqual(self.gen.getrandbits(MyIndex(100)),
823
+ 97904845777343510404718956115)
812
824
813
825
def test_getrandbits_2G_bits(self):
814
826
size = 2**31
0 commit comments