(self, a, b, res, expr="a+b", meth="__add__")
| 96 | self.assertEqual(bm(), res) |
| 97 | |
| 98 | def binop_test(self, a, b, res, expr="a+b", meth="__add__"): |
| 99 | d = {'a': a, 'b': b} |
| 100 | |
| 101 | self.assertEqual(eval(expr, d), res) |
| 102 | t = type(a) |
| 103 | m = getattr(t, meth) |
| 104 | while meth not in t.__dict__: |
| 105 | t = t.__bases__[0] |
| 106 | # in some implementations (e.g. PyPy), 'm' can be a regular unbound |
| 107 | # method object; the getattr() below obtains its underlying function. |
| 108 | self.assertEqual(getattr(m, 'im_func', m), t.__dict__[meth]) |
| 109 | self.assertEqual(m(a, b), res) |
| 110 | bm = getattr(a, meth) |
| 111 | self.assertEqual(bm(b), res) |
| 112 | |
| 113 | def sliceop_test(self, a, b, c, res, expr="a[b:c]", meth="__getitem__"): |
| 114 | d = {'a': a, 'b': b, 'c': c} |
no test coverage detected