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

Method test_readinto

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 3

ZstdFileClass · 0.90
assertEqualMethod · 0.45
readintoMethod · 0.45

Tested by

no test coverage detected