(self, a, b, c, d, res, stmt="a[b:c]=d", meth="__setitem__")
| 163 | self.assertEqual(d['a'], res) |
| 164 | |
| 165 | def setsliceop_test(self, a, b, c, d, res, stmt="a[b:c]=d", meth="__setitem__"): |
| 166 | dictionary = {'a': deepcopy(a), 'b': b, 'c': c, 'd': d} |
| 167 | exec(stmt, dictionary) |
| 168 | self.assertEqual(dictionary['a'], res) |
| 169 | t = type(a) |
| 170 | while meth not in t.__dict__: |
| 171 | t = t.__bases__[0] |
| 172 | m = getattr(t, meth) |
| 173 | # in some implementations (e.g. PyPy), 'm' can be a regular unbound |
| 174 | # method object; the getattr() below obtains its underlying function. |
| 175 | self.assertEqual(getattr(m, 'im_func', m), t.__dict__[meth]) |
| 176 | dictionary['a'] = deepcopy(a) |
| 177 | m(dictionary['a'], slice(b, c), d) |
| 178 | self.assertEqual(dictionary['a'], res) |
| 179 | dictionary['a'] = deepcopy(a) |
| 180 | bm = getattr(dictionary['a'], meth) |
| 181 | bm(slice(b, c), d) |
| 182 | self.assertEqual(dictionary['a'], res) |
| 183 | |
| 184 | def test_lists(self): |
| 185 | # Testing list operations... |
no test coverage detected