aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/test/test_random.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_random.py')
-rw-r--r--Lib/test/test_random.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_random.py b/Lib/test/test_random.py
index 54910cd8054..31ebcb3b8b0 100644
--- a/Lib/test/test_random.py
+++ b/Lib/test/test_random.py
@@ -14,6 +14,15 @@ from test import support
from fractions import Fraction
from collections import abc, Counter
+
+class MyIndex:
+ def __init__(self, value):
+ self.value = value
+
+ def __index__(self):
+ return self.value
+
+
class TestBasicOps:
# Superclass with tests common to all generators.
# Subclasses must arrange for self.gen to retrieve the Random instance
@@ -809,6 +818,9 @@ class MersenneTwister_TestBasicOps(TestBasicOps, unittest.TestCase):
self.gen.seed(1234567)
self.assertEqual(self.gen.getrandbits(100),
97904845777343510404718956115)
+ self.gen.seed(1234567)
+ self.assertEqual(self.gen.getrandbits(MyIndex(100)),
+ 97904845777343510404718956115)
def test_getrandbits_2G_bits(self):
size = 2**31