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

Method set2op_test

Lib/test/test_descr.py:146–163  ·  view source on GitHub ↗
(self, a, b, c, res, stmt="a[b]=c", meth="__setitem__")

Source from the content-addressed store, hash-verified

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}

Callers 4

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

Calls 3

deepcopyFunction · 0.90
mFunction · 0.50
assertEqualMethod · 0.45

Tested by

no test coverage detected