mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
Issue #22777: Test pickling with all protocols.
This commit is contained in:
parent
79b81738ef
commit
bad1257c96
30 changed files with 701 additions and 621 deletions
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue