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

Method setsliceop_test

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

Source from the content-addressed store, hash-verified

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}
167 exec(stmt, dictionary)
168 self.assertEqual(dictionary['a'], res)
169 t = type(a)
170 while meth not in t.__dict__:
171 t = t.__bases__[0]
172 m = getattr(t, meth)
173 # in some implementations (e.g. PyPy), 'm' can be a regular unbound
174 # method object; the getattr() below obtains its underlying function.
175 self.assertEqual(getattr(m, 'im_func', m), t.__dict__[meth])
176 dictionary['a'] = deepcopy(a)
177 m(dictionary['a'], slice(b, c), d)
178 self.assertEqual(dictionary['a'], res)
179 dictionary['a'] = deepcopy(a)
180 bm = getattr(dictionary['a'], meth)
181 bm(slice(b, c), d)
182 self.assertEqual(dictionary['a'], res)
183
184 def test_lists(self):
185 # Testing list operations...

Callers 2

test_listsMethod · 0.95
test_spam_listsMethod · 0.95

Calls 4

deepcopyFunction · 0.90
sliceClass · 0.85
mFunction · 0.50
assertEqualMethod · 0.45

Tested by

no test coverage detected