summaryrefslogtreecommitdiffstats
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.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/Lib/test/test_random.py b/Lib/test/test_random.py
index 103d462..e648045 100644
--- a/Lib/test/test_random.py
+++ b/Lib/test/test_random.py
@@ -159,11 +159,12 @@ class TestBasicOps:
self.assertEqual(y1, y2)
def test_pickling(self):
- state = pickle.dumps(self.gen)
- origseq = [self.gen.random() for i in range(10)]
- newgen = pickle.loads(state)
- restoredseq = [newgen.random() for i in range(10)]
- self.assertEqual(origseq, restoredseq)
+ for proto in range(pickle.HIGHEST_PROTOCOL + 1):
+ state = pickle.dumps(self.gen, proto)
+ origseq = [self.gen.random() for i in range(10)]
+ newgen = pickle.loads(state)
+ restoredseq = [newgen.random() for i in range(10)]
+ self.assertEqual(origseq, restoredseq)
def test_bug_1727780(self):
# verify that version-2-pickles can be loaded
@@ -215,7 +216,8 @@ class SystemRandom_TestBasicOps(TestBasicOps, unittest.TestCase):
self.assertEqual(self.gen.gauss_next, None)
def test_pickling(self):
- self.assertRaises(NotImplementedError, pickle.dumps, self.gen)
+ for proto in range(pickle.HIGHEST_PROTOCOL + 1):
+ self.assertRaises(NotImplementedError, pickle.dumps, self.gen, proto)
def test_53_bits_per_float(self):
# This should pass whenever a C double has 53 bit precision.