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

Method setop_test

Lib/test/test_descr.py:127–144  ·  view source on GitHub ↗
(self, a, b, res, stmt="a+=b", meth="__iadd__")

Source from the content-addressed store, hash-verified

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}

Callers 2

test_listsMethod · 0.95
test_spam_listsMethod · 0.95

Calls 3

deepcopyFunction · 0.90
mFunction · 0.50
assertEqualMethod · 0.45

Tested by

no test coverage detected