diff options
author | Raymond Hettinger <python@rcn.com> | 2007-04-11 18:40:58 +0000 |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2007-04-11 18:40:58 +0000 |
commit | 13936697f60feedd560d16c94e2524453bb1255a (patch) | |
tree | b32c9dd1d973b430e24d8bdc5dc8f2d27317102a /Lib/test | |
parent | c02e13122ba94b05dc03fd56de393b9129f3ed25 (diff) | |
download | cpython-git-13936697f60feedd560d16c94e2524453bb1255a.tar.gz |
SF 1191699: Make slices picklable
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_slice.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/test/test_slice.py b/Lib/test/test_slice.py index c34d9ea4ad..83f051f688 100644 --- a/Lib/test/test_slice.py +++ b/Lib/test/test_slice.py @@ -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) |