(self, a, b, res, stmt="a+=b", meth="__iadd__")
| 125 | self.assertEqual(bm(slice(b, c)), res) |
| 126 | |
| 127 | def setop_test(self, a, b, res, stmt="a+=b", meth="__iadd__"): |
| 128 | d = {'a': deepcopy(a), 'b': b} |
| 129 | exec(stmt, d) |
| 130 | self.assertEqual(d['a'], res) |
| 131 | t = type(a) |
| 132 | m = getattr(t, meth) |
| 133 | while meth not in t.__dict__: |
| 134 | t = t.__bases__[0] |
| 135 | # in some implementations (e.g. PyPy), 'm' can be a regular unbound |
| 136 | # method object; the getattr() below obtains its underlying function. |
| 137 | self.assertEqual(getattr(m, 'im_func', m), t.__dict__[meth]) |
| 138 | d['a'] = deepcopy(a) |
| 139 | m(d['a'], b) |
| 140 | self.assertEqual(d['a'], res) |
| 141 | d['a'] = deepcopy(a) |
| 142 | bm = getattr(d['a'], meth) |
| 143 | bm(b) |
| 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} |
no test coverage detected