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

Method test_index

Lib/test/test_bytes.py:669–687  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

667 self.assertEqual(b.rfind(w, 1, 3), -1)
668
669 def test_index(self):
670 b = self.type2test(b'mississippi')
671 i = 105
672 w = 119
673
674 self.assertEqual(b.index(b'ss'), 2)
675 self.assertRaises(ValueError, b.index, b'w')
676 self.assertRaises(ValueError, b.index, b'mississippian')
677
678 self.assertEqual(b.index(i), 1)
679 self.assertRaises(ValueError, b.index, w)
680
681 self.assertEqual(b.index(b'ss', 3), 5)
682 self.assertEqual(b.index(b'ss', 1, 7), 2)
683 self.assertRaises(ValueError, b.index, b'ss', 1, 3)
684
685 self.assertEqual(b.index(i, 6), 7)
686 self.assertEqual(b.index(i, 1, 3), 1)
687 self.assertRaises(ValueError, b.index, w, 1, 3)
688
689 def test_rindex(self):
690 b = self.type2test(b'mississippi')

Callers

nothing calls this directly

Calls 4

type2testMethod · 0.80
assertEqualMethod · 0.45
indexMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected