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

Method test_RawIOBase_read_bounds_checking

Lib/test/test_io.py:898–912  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

896 self.assertEqual(rawio.read(2), b"")
897
898 def test_RawIOBase_read_bounds_checking(self):
899 # Make sure a `.readinto` call which returns a value outside
900 # (0, len(buffer)) raises.
901 class Misbehaved(self.RawIOBase):
902 def __init__(self, readinto_return) -> None:
903 self._readinto_return = readinto_return
904 def readinto(self, b):
905 return self._readinto_return
906
907 with self.assertRaises(ValueError) as cm:
908 Misbehaved(2).read(1)
909 self.assertEqual(str(cm.exception), "readinto returned 2 outside buffer size 1")
910 for bad_size in (2147483647, sys.maxsize, -1, -1000):
911 with self.assertRaises(ValueError):
912 Misbehaved(bad_size).read()
913
914 def test_types_have_dict(self):
915 test = (

Callers

nothing calls this directly

Calls 5

MisbehavedClass · 0.85
strFunction · 0.85
assertRaisesMethod · 0.45
readMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected