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

Method sliceop_test

Lib/test/test_descr.py:113–125  ·  view source on GitHub ↗
(self, a, b, c, res, expr="a[b:c]", meth="__getitem__")

Source from the content-addressed store, hash-verified

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}
115 self.assertEqual(eval(expr, d), res)
116 t = type(a)
117 m = getattr(t, meth)
118 while meth not in t.__dict__:
119 t = t.__bases__[0]
120 # in some implementations (e.g. PyPy), 'm' can be a regular unbound
121 # method object; the getattr() below obtains its underlying function.
122 self.assertEqual(getattr(m, 'im_func', m), t.__dict__[meth])
123 self.assertEqual(m(a, slice(b, c)), res)
124 bm = getattr(a, meth)
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}

Callers 2

test_listsMethod · 0.95
test_spam_listsMethod · 0.95

Calls 3

sliceClass · 0.85
mFunction · 0.50
assertEqualMethod · 0.45

Tested by

no test coverage detected