(self, a, b, c, res, stmt="a[b]=c", meth="__setitem__")
| 144 | self.assertEqual(d['a'], res) |
| 145 | |
| 146 | def set2op_test(self, a, b, c, res, stmt="a[b]=c", meth="__setitem__"): |
| 147 | d = {'a': deepcopy(a), 'b': b, 'c': c} |
| 148 | exec(stmt, d) |
| 149 | self.assertEqual(d['a'], res) |
| 150 | t = type(a) |
| 151 | m = getattr(t, meth) |
| 152 | while meth not in t.__dict__: |
| 153 | t = t.__bases__[0] |
| 154 | # in some implementations (e.g. PyPy), 'm' can be a regular unbound |
| 155 | # method object; the getattr() below obtains its underlying function. |
| 156 | self.assertEqual(getattr(m, 'im_func', m), t.__dict__[meth]) |
| 157 | d['a'] = deepcopy(a) |
| 158 | m(d['a'], b, c) |
| 159 | self.assertEqual(d['a'], res) |
| 160 | d['a'] = deepcopy(a) |
| 161 | bm = getattr(d['a'], meth) |
| 162 | bm(b, c) |
| 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} |
no test coverage detected