MCPcopy Index your code
hub / github.com/python/cpython / binop_test

Method binop_test

Lib/test/test_descr.py:98–111  ·  view source on GitHub ↗
(self, a, b, res, expr="a+b", meth="__add__")

Source from the content-addressed store, hash-verified

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}

Callers 5

test_listsMethod · 0.95
test_dictsMethod · 0.95
number_operatorsMethod · 0.95
test_spam_listsMethod · 0.95
test_spam_dictsMethod · 0.95

Calls 2

mFunction · 0.50
assertEqualMethod · 0.45

Tested by

no test coverage detected