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

Method test_find

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

Source from the content-addressed store, hash-verified

623 self.assertIn('tuple', exc)
624
625 def test_find(self):
626 b = self.type2test(b'mississippi')
627 i = 105
628 w = 119
629
630 self.assertEqual(b.find(b'ss'), 2)
631 self.assertEqual(b.find(b'w'), -1)
632 self.assertEqual(b.find(b'mississippian'), -1)
633
634 self.assertEqual(b.find(i), 1)
635 self.assertEqual(b.find(w), -1)
636
637 self.assertEqual(b.find(b'ss', 3), 5)
638 self.assertEqual(b.find(b'ss', 1, 7), 2)
639 self.assertEqual(b.find(b'ss', 1, 3), -1)
640
641 self.assertEqual(b.find(i, 6), 7)
642 self.assertEqual(b.find(i, 1, 3), 1)
643 self.assertEqual(b.find(w, 1, 3), -1)
644
645 for index in (-1, 256, sys.maxsize + 1):
646 self.assertRaisesRegex(
647 ValueError, r'byte must be in range\(0, 256\)',
648 b.find, index)
649
650 def test_rfind(self):
651 b = self.type2test(b'mississippi')

Callers

nothing calls this directly

Calls 4

type2testMethod · 0.80
assertRaisesRegexMethod · 0.80
assertEqualMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected