mirror of
https://github.com/python/cpython
synced 2024-09-04 15:56:13 +00:00
Whoops, I missed a few more places that were using slicing from the operator module
This commit is contained in:
parent
425136be01
commit
953e4e52c4
|
@ -57,11 +57,8 @@ def test_simple(self):
|
|||
|
||||
self.failUnlessEqual(len(ca), 3)
|
||||
|
||||
# slicing is now supported, but not extended slicing (3-argument)!
|
||||
from operator import getslice, delitem
|
||||
self.assertRaises(TypeError, getslice, ca, 0, 1, -1)
|
||||
|
||||
# cannot delete items
|
||||
from operator import delitem
|
||||
self.assertRaises(TypeError, delitem, ca, 0)
|
||||
|
||||
def test_numeric_arrays(self):
|
||||
|
|
|
@ -45,21 +45,17 @@ def test_setslice_cint(self):
|
|||
b[33::-3] = range(12)
|
||||
self.failUnlessEqual(a[:], b)
|
||||
|
||||
from operator import setslice, setitem
|
||||
from operator import setitem
|
||||
|
||||
# TypeError: int expected instead of str instance
|
||||
self.assertRaises(TypeError, setslice, a, 0, 5, "abcde")
|
||||
self.assertRaises(TypeError, setitem, a, slice(0, 5), "abcde")
|
||||
# TypeError: int expected instead of str instance
|
||||
self.assertRaises(TypeError, setslice, a, 0, 5, ["a", "b", "c", "d", "e"])
|
||||
self.assertRaises(TypeError, setitem, a, slice(0, 5),
|
||||
["a", "b", "c", "d", "e"])
|
||||
# TypeError: int expected instead of float instance
|
||||
self.assertRaises(TypeError, setslice, a, 0, 5, [1, 2, 3, 4, 3.14])
|
||||
self.assertRaises(TypeError, setitem, a, slice(0, 5),
|
||||
[1, 2, 3, 4, 3.14])
|
||||
# ValueError: Can only assign sequence of same size
|
||||
self.assertRaises(ValueError, setslice, a, 0, 5, range(32))
|
||||
self.assertRaises(ValueError, setitem, a, slice(0, 5), range(32))
|
||||
|
||||
def test_char_ptr(self):
|
||||
|
@ -86,8 +82,6 @@ def test_char_ptr(self):
|
|||
self.assertRaises(ValueError, operator.getitem,
|
||||
res, slice(-5, None, None))
|
||||
|
||||
self.assertRaises(TypeError, operator.setslice,
|
||||
res, 0, 5, "abcde")
|
||||
self.assertRaises(TypeError, operator.setitem,
|
||||
res, slice(0, 5), "abcde")
|
||||
dll.my_free(res)
|
||||
|
@ -150,8 +144,6 @@ def test_wchar_ptr(self):
|
|||
self.failUnlessEqual(res[len(s)-1:5:-7], s[:5:-7])
|
||||
|
||||
import operator
|
||||
self.assertRaises(TypeError, operator.setslice,
|
||||
res, 0, 5, "abcde")
|
||||
self.assertRaises(TypeError, operator.setitem,
|
||||
res, slice(0, 5), "abcde")
|
||||
dll.my_free(res)
|
||||
|
|
|
@ -137,15 +137,6 @@ def test_delitem(self):
|
|||
self.failUnless(operator.delitem(a, 1) is None)
|
||||
self.assert_(a == [4, 2, 1])
|
||||
|
||||
def test_delslice(self):
|
||||
a = list(range(10))
|
||||
self.failUnlessRaises(TypeError, operator.delslice, a)
|
||||
self.failUnlessRaises(TypeError, operator.delslice, a, None, None)
|
||||
self.failUnless(operator.delslice(a, 2, 8) is None)
|
||||
self.assert_(a == [0, 1, 8, 9])
|
||||
operator.delslice(a, 0, test_support.MAX_Py_ssize_t)
|
||||
self.assertEqual(a, [])
|
||||
|
||||
def test_floordiv(self):
|
||||
self.failUnlessRaises(TypeError, operator.floordiv, 5)
|
||||
self.failUnlessRaises(TypeError, operator.floordiv, None, None)
|
||||
|
@ -162,14 +153,6 @@ def test_getitem(self):
|
|||
self.failUnlessRaises(TypeError, operator.getitem, a, None)
|
||||
self.failUnless(operator.getitem(a, 2) == 2)
|
||||
|
||||
def test_getslice(self):
|
||||
a = list(range(10))
|
||||
self.failUnlessRaises(TypeError, operator.getslice)
|
||||
self.failUnlessRaises(TypeError, operator.getslice, a, None, None)
|
||||
self.failUnless(operator.getslice(a, 4, 6) == [4, 5])
|
||||
b = operator.getslice(a, 0, test_support.MAX_Py_ssize_t)
|
||||
self.assertEqual(b, a)
|
||||
|
||||
def test_indexOf(self):
|
||||
self.failUnlessRaises(TypeError, operator.indexOf)
|
||||
self.failUnlessRaises(TypeError, operator.indexOf, None, None)
|
||||
|
@ -298,15 +281,6 @@ def test_setitem(self):
|
|||
self.assert_(a == [2, 1, 2])
|
||||
self.assertRaises(IndexError, operator.setitem, a, 4, 2)
|
||||
|
||||
def test_setslice(self):
|
||||
a = list(range(4))
|
||||
self.failUnlessRaises(TypeError, operator.setslice, a)
|
||||
self.failUnlessRaises(TypeError, operator.setslice, a, None, None, None)
|
||||
self.failUnless(operator.setslice(a, 1, 3, [2, 1]) is None)
|
||||
self.assert_(a == [0, 2, 1, 3])
|
||||
operator.setslice(a, 0, test_support.MAX_Py_ssize_t, [])
|
||||
self.assertEqual(a, [])
|
||||
|
||||
def test_sub(self):
|
||||
self.failUnlessRaises(TypeError, operator.sub)
|
||||
self.failUnlessRaises(TypeError, operator.sub, None, None)
|
||||
|
|
Loading…
Reference in a new issue