diff options
author | Thomas Wouters <thomas@python.org> | 2007-08-30 22:57:53 (GMT) |
---|---|---|
committer | Thomas Wouters <thomas@python.org> | 2007-08-30 22:57:53 (GMT) |
commit | d2cf20eea2338a0369d4a5707adb01b201f7dfb2 (patch) | |
tree | 59fd4a094906997ae2b0cd520ff09010457da680 /Lib/test/test_class.py | |
parent | 582b5866174d20f7c027cbb6fb757fefb382f96f (diff) | |
download | cpython-d2cf20eea2338a0369d4a5707adb01b201f7dfb2.zip cpython-d2cf20eea2338a0369d4a5707adb01b201f7dfb2.tar.gz cpython-d2cf20eea2338a0369d4a5707adb01b201f7dfb2.tar.bz2 |
Remove the simple slicing API. All slicing is now done with slice objects.
Diffstat (limited to 'Lib/test/test_class.py')
-rw-r--r-- | Lib/test/test_class.py | 41 |
1 files changed, 4 insertions, 37 deletions
diff --git a/Lib/test/test_class.py b/Lib/test/test_class.py index bde63a8..76b30a3 100644 --- a/Lib/test/test_class.py +++ b/Lib/test/test_class.py @@ -36,11 +36,8 @@ testmeths = [ # List/dict operations "contains", "getitem", - "getslice", "setitem", - "setslice", "delitem", - "delslice", # Unary operations "neg", @@ -288,15 +285,16 @@ class ClassTests(unittest.TestCase): callLst[:] = [] testme[:42] - self.assertCallStack([('__getslice__', (testme, 0, 42))]) + self.assertCallStack([('__getitem__', (testme, slice(None, 42)))]) callLst[:] = [] testme[:42] = "The Answer" - self.assertCallStack([('__setslice__', (testme, 0, 42, "The Answer"))]) + self.assertCallStack([('__setitem__', (testme, slice(None, 42), + "The Answer"))]) callLst[:] = [] del testme[:42] - self.assertCallStack([('__delslice__', (testme, 0, 42))]) + self.assertCallStack([('__delitem__', (testme, slice(None, 42)))]) callLst[:] = [] testme[2:1024:10] @@ -329,37 +327,6 @@ class ClassTests(unittest.TestCase): slice(None, 24, None), 24, 100)))]) - # Now remove the slice hooks to see if converting normal slices to - # slice object works. - - getslice = AllTests.__getslice__ - del AllTests.__getslice__ - setslice = AllTests.__setslice__ - del AllTests.__setslice__ - delslice = AllTests.__delslice__ - del AllTests.__delslice__ - - # XXX when using new-style classes the slice testme[:42] produces - # slice(None, 42, None) instead of slice(0, 42, None). py3k will have - # to change this test. - callLst[:] = [] - testme[0:42] - self.assertCallStack([('__getitem__', (testme, slice(0, 42, None)))]) - - callLst[:] = [] - testme[:42] = "The Answer" - self.assertCallStack([('__setitem__', (testme, slice(None, 42, None), - "The Answer"))]) - callLst[:] = [] - del testme[0:42] - self.assertCallStack([('__delitem__', (testme, slice(0, 42, None)))]) - - # Restore the slice methods, or the tests will fail with regrtest -R. - AllTests.__getslice__ = getslice - AllTests.__setslice__ = setslice - AllTests.__delslice__ = delslice - - def testUnaryOps(self): testme = AllTests() |