diff options
Diffstat (limited to 'Lib/test/test_slice.py')
-rw-r--r-- | Lib/test/test_slice.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/Lib/test/test_slice.py b/Lib/test/test_slice.py index f22f619..977b28a 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 @@ -92,6 +93,24 @@ class SliceTest(unittest.TestCase): self.assertRaises(OverflowError, slice(None).indices, 1<<100) + def test_setslice_without_getslice(self): + tmp = [] + class X(object): + def __setslice__(self, i, j, k): + tmp.append((i, j, k)) + + x = X() + 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) |