MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_index

Method test_index

Lib/test/test_memoryview.py:63–86  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

61 self.check_getitem_with_type(tp)
62
63 def test_index(self):
64 for tp in self._types:
65 b = tp(self._source)
66 m = self._view(b) # may be a sub-view
67 l = m.tolist()
68 k = 2 * len(self._source)
69
70 for chi in self._source:
71 if chi in l:
72 self.assertEqual(m.index(chi), l.index(chi))
73 else:
74 self.assertRaises(ValueError, m.index, chi)
75
76 for start, stop in product(range(-k, k), range(-k, k)):
77 index = -1
78 try:
79 index = l.index(chi, start, stop)
80 except ValueError:
81 pass
82
83 if index == -1:
84 self.assertRaises(ValueError, m.index, chi, start, stop)
85 else:
86 self.assertEqual(m.index(chi, start, stop), index)
87
88 def test_iter(self):
89 for tp in self._types:

Callers

nothing calls this directly

Calls 6

lenFunction · 0.85
_viewMethod · 0.45
tolistMethod · 0.45
assertEqualMethod · 0.45
indexMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected