mirror of
https://github.com/python/cpython.git
synced 2025-11-25 04:34:37 +00:00
SF 1191699: Make slices picklable
This commit is contained in:
parent
c02e13122b
commit
13936697f6
3 changed files with 20 additions and 0 deletions
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
import unittest
|
||||
from test import test_support
|
||||
from cPickle import loads, dumps
|
||||
|
||||
import sys
|
||||
|
||||
|
|
@ -102,6 +103,13 @@ class SliceTest(unittest.TestCase):
|
|||
x[1:2] = 42
|
||||
self.assertEquals(tmp, [(1, 2, 42)])
|
||||
|
||||
def test_pickle(self):
|
||||
s = slice(10, 20, 3)
|
||||
for protocol in (0,1,2):
|
||||
t = loads(dumps(s, protocol))
|
||||
self.assertEqual(s, t)
|
||||
self.assertEqual(s.indices(15), t.indices(15))
|
||||
self.assertNotEqual(id(s), id(t))
|
||||
|
||||
def test_main():
|
||||
test_support.run_unittest(SliceTest)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue