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

Method test_readinto

Lib/test/test_zstd.py:2014–2029  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2012 self.assertRaises(TypeError, f.read1, None)
2013
2014 def test_readinto(self):
2015 arr = array.array("I", range(100))
2016 self.assertEqual(len(arr), 100)
2017 self.assertEqual(len(arr) * arr.itemsize, 400)
2018 ba = bytearray(300)
2019 with ZstdFile(io.BytesIO(COMPRESSED_100_PLUS_32KB)) as f:
2020 # 0 length output buffer
2021 self.assertEqual(f.readinto(ba[0:0]), 0)
2022
2023 # use correct length for buffer protocol object
2024 self.assertEqual(f.readinto(arr), 400)
2025 self.assertEqual(arr.tobytes(), DECOMPRESSED_100_PLUS_32KB[:400])
2026
2027 # normal readinto
2028 self.assertEqual(f.readinto(ba), 300)
2029 self.assertEqual(ba, DECOMPRESSED_100_PLUS_32KB[400:700])
2030
2031 def test_peek(self):
2032 with ZstdFile(io.BytesIO(DAT_130K_C)) as f:

Callers

nothing calls this directly

Calls 5

ZstdFileClass · 0.90
lenFunction · 0.85
assertEqualMethod · 0.45
readintoMethod · 0.45
tobytesMethod · 0.45

Tested by

no test coverage detected