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

Method test_readinto1_array

Lib/test/test_io/test_bufferedio.py:360–379  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

358 self.assertEqual(bm[n:], b'x' * (len(bm[n:])))
359
360 def test_readinto1_array(self):
361 buffer_size = 60
362 data = b"a" * 26
363 rawio = self.MockRawIO((data,))
364 bufio = self.tp(rawio, buffer_size=buffer_size)
365
366 # Create an array with element size > 1 byte
367 b = array.array('i', b'x' * 32)
368 assert len(b) != 16
369
370 # Read into it. We should get as many *bytes* as we can fit into b
371 # (which is more than the number of elements)
372 n = bufio.readinto1(b)
373 self.assertGreater(n, len(b))
374
375 # Check that old contents of b are preserved
376 bm = memoryview(b).cast('B')
377 self.assertLess(n, len(bm))
378 self.assertEqual(bm[:n], data[:n])
379 self.assertEqual(bm[n:], b'x' * (len(bm[n:])))
380
381 def test_readlines(self):
382 def bufio():

Callers

nothing calls this directly

Calls 5

assertGreaterMethod · 0.80
castMethod · 0.80
readinto1Method · 0.45
assertLessMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected