mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
Issue 2582: Fix pickling of range objects.
This commit is contained in:
parent
1c9a2d96ec
commit
7505607ae7
2 changed files with 19 additions and 0 deletions
|
@ -2,6 +2,7 @@
|
|||
|
||||
import test.support, unittest
|
||||
import sys
|
||||
import pickle
|
||||
|
||||
import warnings
|
||||
warnings.filterwarnings("ignore", "integer argument expected",
|
||||
|
@ -61,6 +62,15 @@ class RangeTest(unittest.TestCase):
|
|||
self.assertEqual(repr(range(1, 2)), 'range(1, 2)')
|
||||
self.assertEqual(repr(range(1, 2, 3)), 'range(1, 2, 3)')
|
||||
|
||||
def test_pickling(self):
|
||||
testcases = [(13,), (0, 11), (-22, 10), (20, 3, -1),
|
||||
(13, 21, 3), (-2, 2, 2)]
|
||||
for proto in range(pickle.HIGHEST_PROTOCOL):
|
||||
for t in testcases:
|
||||
r = range(*t)
|
||||
self.assertEquals(list(pickle.loads(pickle.dumps(r, proto))),
|
||||
list(r))
|
||||
|
||||
def test_main():
|
||||
test.support.run_unittest(RangeTest)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue