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

Method test_index

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

Source from the content-addressed store, hash-verified

741 self.assertEqual(b.rfind(w, 1, 3), -1)
742
743 def test_index(self):
744 b = self.type2test(b'mississippi')
745 i = 105
746 w = 119
747
748 self.assertEqual(b.index(b'ss'), 2)
749 self.assertRaises(ValueError, b.index, b'w')
750 self.assertRaises(ValueError, b.index, b'mississippian')
751
752 self.assertEqual(b.index(i), 1)
753 self.assertRaises(ValueError, b.index, w)
754
755 self.assertEqual(b.index(b'ss', 3), 5)
756 self.assertEqual(b.index(b'ss', 1, 7), 2)
757 self.assertRaises(ValueError, b.index, b'ss', 1, 3)
758
759 self.assertEqual(b.index(i, 6), 7)
760 self.assertEqual(b.index(i, 1, 3), 1)
761 self.assertRaises(ValueError, b.index, w, 1, 3)
762
763 def test_rindex(self):
764 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