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

Method check_indices

Lib/test/test_slice.py:149–163  ·  view source on GitHub ↗
(self, slice, length)

Source from the content-addressed store, hash-verified

147 self.assertTrue(s.stop is obj)
148
149 def check_indices(self, slice, length):
150 try:
151 actual = slice.indices(length)
152 except ValueError:
153 actual = "valueerror"
154 try:
155 expected = slice_indices(slice, length)
156 except ValueError:
157 expected = "valueerror"
158 self.assertEqual(actual, expected)
159
160 if length >= 0 and slice.step != 0:
161 actual = range(*slice.indices(length))
162 expected = range(length)[slice]
163 self.assertEqual(actual, expected)
164
165 def test_indices(self):
166 self.assertEqual(slice(None ).indices(10), (0, 10, 1))

Callers 1

test_indicesMethod · 0.95

Calls 2

slice_indicesFunction · 0.85
assertEqualMethod · 0.45

Tested by

no test coverage detected